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 urllib3
import yaml
import json
from prometheus_client import Gauge, start_http_server, Summary, Counter, Histogram
@@ -20,7 +19,7 @@ class HostConfig:
fqdn: str
username: str
password: str
systemid: list[str] | None = None
chassis: list[str] | None = None
max_retries: int = 1
backoff: int = 2
cool_down: int = 120 # seconds to wait after too many failures
@@ -243,10 +242,10 @@ async def get_power_data(session, host: HostConfig):
continue
# 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")
if hasattr(host, 'systemid') and host.systemid:
if chassis_id not in host.systemid:
if hasattr(host, "chassis") and host.chassis:
if chassis_member_id not in host.chassis:
continue
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)
default_username = config.get("username")
default_password = config.get("password")
default_systemid = config.get("systemid")
default_chassis = config.get("chassis")
hosts = config["hosts"]
interval = config.get("interval", 10)
@@ -372,7 +371,7 @@ async def run_exporter(config, stop_event):
fqdn=host_entry["fqdn"],
username=host_entry.get("username", default_username),
password=host_entry.get("password", default_password),
systemid=host_entry.get("systemid", default_systemid),
chassis=host_entry.get("chassis", default_chassis),
)
else:
hc = HostConfig(