publish my redfish_exporter

This commit is contained in:
2025-11-13 10:29:29 +01:00
parent 581df6617b
commit 5e68842356
8 changed files with 525 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import requests
import urllib3
# import sys
urllib3.disable_warnings()
username = "<user>"
password = "<password>"
# host = sys.argv[1]
def get_power_data(host):
"""Redfish API Chassis Power"""
url = f"https://{host}.mgmt.wtb1.ch.abainfra.net/redfish/v1/Chassis/1/Power"
response = requests.get(url, auth=(username, password), verify=False)
if response.status_code == 200:
data = response.json()
for idx, psu in enumerate(data.get("PowerSupplies", [])):
line_input_v = psu.get("LineInputVoltage")
watts_input = psu.get("PowerInputWatts")
serial = psu.get("SerialNumber")
print(
f"PSU {idx}, {serial}: {host}, {line_input_v} V, {watts_input} W, {round(watts_input/line_input_v,2)} A"
)
else:
print(f"Error {response.status_code}: {response.text}")
# loop over each hosts
hosts = [
"srv1-112",
]
for host in hosts:
get_power_data(host)