update some comments

This commit is contained in:
2026-01-29 16:01:46 +01:00
parent 0b8e183f98
commit 5a66ca82cb

View File

@@ -213,7 +213,7 @@ async def get_power_data(session, host: HostConfig):
up_gauge.labels(host=host.fqdn).set(0) up_gauge.labels(host=host.fqdn).set(0)
return return
# start time measurement # Start time measurement
start = time.monotonic() start = time.monotonic()
# Root ressource abfragen # Root ressource abfragen
resources = await discover_redfish_resources(session, host) resources = await discover_redfish_resources(session, host)
@@ -227,7 +227,7 @@ async def get_power_data(session, host: HostConfig):
host.mark_success() host.mark_success()
up_gauge.labels(host=host.fqdn).set(1) up_gauge.labels(host=host.fqdn).set(1)
# Chassis-Ressource abfragen # Get chassis ressource
chassis_url = f"https://{host.fqdn}{resources['Chassis']}" chassis_url = f"https://{host.fqdn}{resources['Chassis']}"
chassis_data = await fetch_with_retry(session, host, chassis_url) chassis_data = await fetch_with_retry(session, host, chassis_url)
if not chassis_data: if not chassis_data:
@@ -235,13 +235,13 @@ async def get_power_data(session, host: HostConfig):
up_gauge.labels(host=host.fqdn).set(0) up_gauge.labels(host=host.fqdn).set(0)
return return
# 3. Power-Daten aus den Chassis-Mitgliedern extrahieren # loop over each member in chassis ressource
for chassis_member in chassis_data.get("Members", []): for chassis_member in chassis_data.get("Members", []):
chassis_member_url = chassis_member.get("@odata.id") chassis_member_url = chassis_member.get("@odata.id")
if not chassis_member_url: if not chassis_member_url:
continue continue
# Get Chassis ID from url ("/redfish/v1/Chassis/1" -> 1) # Get chassis id from url ("/redfish/v1/Chassis/1" -> 1)
chassis_member_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, "chassis") and host.chassis: if hasattr(host, "chassis") and host.chassis:
@@ -259,7 +259,7 @@ async def get_power_data(session, host: HostConfig):
logging.warning("No PowerSubsystem found for %s", host.fqdn) logging.warning("No PowerSubsystem found for %s", host.fqdn)
continue continue
# PowerSubsystem collection abfragen # Get PowerSubsystem collection
power_subsystem_url = f"https://{host.fqdn}{power_subsystem_url}" power_subsystem_url = f"https://{host.fqdn}{power_subsystem_url}"
power_subsystem_data = await fetch_with_retry( power_subsystem_data = await fetch_with_retry(
session, host, power_subsystem_url session, host, power_subsystem_url
@@ -268,7 +268,7 @@ async def get_power_data(session, host: HostConfig):
logging.warning("No PowerSubsystem data found for %s", host.fqdn) logging.warning("No PowerSubsystem data found for %s", host.fqdn)
continue continue
# PowerSupplies auflisten # Get PowerSupplies url
power_supplies_url = power_subsystem_data.get("PowerSupplies", {}).get( power_supplies_url = power_subsystem_data.get("PowerSupplies", {}).get(
"@odata.id" "@odata.id"
) )
@@ -276,13 +276,13 @@ async def get_power_data(session, host: HostConfig):
logging.warning("No PowerSupplies found for %s", host.fqdn) logging.warning("No PowerSupplies found for %s", host.fqdn)
continue continue
# PowerSupplies Members auflisten # List PowerSupplies members
power_supplies_url = f"https://{host.fqdn}{power_supplies_url}" power_supplies_url = f"https://{host.fqdn}{power_supplies_url}"
power_supplies_data = await fetch_with_retry(session, host, power_supplies_url) power_supplies_data = await fetch_with_retry(session, host, power_supplies_url)
if not power_supplies_data: if not power_supplies_data:
continue continue
# Loop over PowerSupply Members # Loop over PowerSupply members
for psu_member in power_supplies_data.get("Members", []): for psu_member in power_supplies_data.get("Members", []):
psu_url = psu_member.get("@odata.id") psu_url = psu_member.get("@odata.id")
if not psu_url: if not psu_url:
@@ -311,7 +311,6 @@ async def get_power_data(session, host: HostConfig):
watts_input = metrics_data.get("InputPowerWatts", {}).get("Reading") watts_input = metrics_data.get("InputPowerWatts", {}).get("Reading")
amps_input = metrics_data.get("InputCurrentAmps", {}).get("Reading") amps_input = metrics_data.get("InputCurrentAmps", {}).get("Reading")
serial = psu_data.get("SerialNumber") serial = psu_data.get("SerialNumber")
# Calculate Amps
if line_input_v is not None: if line_input_v is not None:
voltage_gauge.labels(host=host.fqdn, psu_serial=serial).set( voltage_gauge.labels(host=host.fqdn, psu_serial=serial).set(
line_input_v line_input_v
@@ -384,7 +383,9 @@ async def run_exporter(config, stop_event):
async with aiohttp.ClientSession(connector=connector) as session: async with aiohttp.ClientSession(connector=connector) as session:
try: try:
while not stop_event.is_set(): while not stop_event.is_set():
tasks = [get_power_data(session, hc) for hc in host_objs] tasks = []
for hc in host_objs:
tasks.append(get_power_data(session, hc))
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
await process_request(interval) await process_request(interval)
finally: finally:
@@ -397,8 +398,6 @@ async def run_exporter(config, stop_event):
logging.info("Exporter stopped cleanly.") logging.info("Exporter stopped cleanly.")
# ab hier neu
# Marco Lucarelli 2026-01-29
async def discover_redfish_resources(session, host: HostConfig) -> dict: async def discover_redfish_resources(session, host: HostConfig) -> dict:
"""Discover available Redfish resources and return relevant URLs""" """Discover available Redfish resources and return relevant URLs"""
root_url = f"https://{host.fqdn}/redfish/v1/" root_url = f"https://{host.fqdn}/redfish/v1/"