changed systemids to chassis

This commit is contained in:
2026-01-29 15:39:44 +01:00
parent 2f249beb8a
commit 42efa7c1c8

View File

@@ -9,7 +9,6 @@ import asyncio
import aiohttp import aiohttp
import urllib3 import urllib3
import yaml import yaml
import json
from prometheus_client import Gauge, start_http_server, Summary, Counter, Histogram from prometheus_client import Gauge, start_http_server, Summary, Counter, Histogram
@@ -20,7 +19,7 @@ class HostConfig:
fqdn: str fqdn: str
username: str username: str
password: str password: str
systemid: list[str] | None = None chassis: list[str] | None = None
max_retries: int = 1 max_retries: int = 1
backoff: int = 2 backoff: int = 2
cool_down: int = 120 # seconds to wait after too many failures cool_down: int = 120 # seconds to wait after too many failures
@@ -243,10 +242,10 @@ async def get_power_data(session, host: HostConfig):
continue continue
# Get Chassis ID from url ("/redfish/v1/Chassis/1" -> 1) # Get Chassis ID from url ("/redfish/v1/Chassis/1" -> 1)
chassis_id = chassis_member_url.split("/")[-1] chassis_member_id = chassis_member_url.split("/")[-1]
# Check if the chassis id is in config (had problem with chassis "NVMe") # Check if the chassis id is in config (had problem with chassis "NVMe")
if hasattr(host, 'systemid') and host.systemid: if hasattr(host, "chassis") and host.chassis:
if chassis_id not in host.systemid: if chassis_member_id not in host.chassis:
continue continue
member_url = f"https://{host.fqdn}{chassis_member_url}" member_url = f"https://{host.fqdn}{chassis_member_url}"
@@ -356,7 +355,7 @@ async def run_exporter(config, stop_event):
port = config.get("port", 8000) port = config.get("port", 8000)
default_username = config.get("username") default_username = config.get("username")
default_password = config.get("password") default_password = config.get("password")
default_systemid = config.get("systemid") default_chassis = config.get("chassis")
hosts = config["hosts"] hosts = config["hosts"]
interval = config.get("interval", 10) interval = config.get("interval", 10)
@@ -372,7 +371,7 @@ async def run_exporter(config, stop_event):
fqdn=host_entry["fqdn"], fqdn=host_entry["fqdn"],
username=host_entry.get("username", default_username), username=host_entry.get("username", default_username),
password=host_entry.get("password", default_password), password=host_entry.get("password", default_password),
systemid=host_entry.get("systemid", default_systemid), chassis=host_entry.get("chassis", default_chassis),
) )
else: else:
hc = HostConfig( hc = HostConfig(