This commit is contained in:
2026-01-29 16:12:49 +01:00
parent 5a66ca82cb
commit ed3948c72f

View File

@@ -78,6 +78,10 @@ amps_gauge = Gauge(
"redfish_psu_input_amps", "Current draw in Amps per PSU", ["host", "psu_serial"] "redfish_psu_input_amps", "Current draw in Amps per PSU", ["host", "psu_serial"]
) )
system_redfish_gauge = Gauge(
"system_redfish_version", "Current Redfish Version", ["host", "redfish_version"]
)
@REQUEST_TIME.time() @REQUEST_TIME.time()
async def process_request(t): async def process_request(t):
@@ -205,7 +209,7 @@ async def fetch_with_retry(session, host: HostConfig, url: str) -> dict | None:
async def get_power_data(session, host: HostConfig): async def get_power_data(session, host: HostConfig):
"""Query Redfish and update Prometheus metrics""" """Query Redfish for power data and update Prometheus metrics"""
if host.should_skip(): if host.should_skip():
logging.warning( logging.warning(
"Skipping %s (in cool-down until %.1f)", host.fqdn, host.next_retry_time "Skipping %s (in cool-down until %.1f)", host.fqdn, host.next_retry_time
@@ -322,6 +326,52 @@ async def get_power_data(session, host: HostConfig):
REQUEST_LATENCY.labels(host=host.fqdn).observe(time.monotonic() - start) REQUEST_LATENCY.labels(host=host.fqdn).observe(time.monotonic() - start)
async def get_system_info(session, host: HostConfig):
"""Query Redfish for system data and update Prometheus metrics"""
if host.should_skip():
logging.warning(
"Skipping %s (in cool-down until %.1f)", host.fqdn, host.next_retry_time
)
return
# Get Vendor and Redfish Version
root_url = f"https://{host.fqdn}/redfish/v1/"
root_data = await fetch_with_retry(session, host, root_url)
if not root_data:
host.mark_failure()
return
redfish_version = root_data.get("RedfishVersion")
vendor = root_data.get("Vendor")
# Get Manufacturer, Serial and Model
systems_url = f"https://{host.fqdn}/redfish/v1/Systems/"
systems_data = await fetch_with_retry(session, host, systems_url)
if not systems_data:
host.mark_failure()
return
system_redfish_gauge.labels(host=host.fqdn, redfish_version=redfish_version).set(redfish_version)
# loop for each system members
for system_member in systems_data.get("Members", []):
system_url = system_member.get("@odata.id")
if not system_url:
continue
system_data = await fetch_with_retry(session, host, f"https://{host.fqdn}{system_url}")
if not system_data:
continue
manufacturer = system_data.get("Manufacturer")
model = system_data.get("Model")
serial_number = system_data.get("SerialNumber")
# Hier könnte ihre Werbung stehen
system_info_gauge.labels(host=host.fqdn, metric="vendor").set(1 if vendor else 0)
system_info_gauge.labels(host=host.fqdn, metric="manufacturer").set(1 if manufacturer else 0)
async def logout_host(session, host): async def logout_host(session, host):
"""Clean logout for Redfish with session tokens""" """Clean logout for Redfish with session tokens"""