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