Files
my_projects/python/redfish-api
2026-01-29 13:11:55 +01:00
..
2026-01-21 08:32:42 +01:00
2025-11-13 10:29:29 +01:00
2026-01-21 08:35:27 +01:00
2026-01-21 08:32:42 +01:00
2026-01-21 08:32:42 +01:00
2025-11-13 10:29:29 +01:00
2026-01-21 08:35:27 +01:00
2025-11-13 10:29:29 +01:00
2026-01-29 13:11:55 +01:00

Description

I've createtd this python script to collect Power data to analyse Watts, Volts and Amperes. If there is a better solution, feel free to replace me.

Usage:

usage: redfish_exporter.py [-h] [--config CONFIG] [--port PORT]

Redfish Prometheus Exporter

options:
  -h, --help       show this help message and exit
  --config CONFIG  Path to config file
  --port PORT      Override port from config file

Install

Requirements

Dependencies:

  • see requirements.txt

Configuration

Create config.yaml:

---
interval: 5
port: 8000
username: user1
password: secret
hosts:
  - srv1-112.mgmt.wtb1.ch.abainfra.net
  - srv2-112.mgmt.wtb1.ch.abainfra.net
  - srv3-112.mgmt.wtb1.ch.abainfra.net
  - srv4-112.mgmt.wtb1.ch.abainfra.net

or:

---
interval: 5
port: 8000
username: user1
password: secret1
hosts:
  - fqdn: srv1-112.mgmt.wtb1.ch.abainfra.net
    username: user2
    password: secret2
  - fqdn: srv2-112.mgmt.wtb1.ch.abainfra.net
    username: user3
    password: secret3
  - fqdn: srv3-112.mgmt.wtb1.ch.abainfra.net
    username: user4
    password: secret4
  - fqdn: srv4-112.mgmt.wtb1.ch.abainfra.net
    username: user5
    password: secret5

The port, interval are optional and can be overwritten by argument. Save default values are hardcoded.

Use as Container

docker build -t redfish_exporter .
docker run -it --rm --name redfish_exporter_app -p 8000:8000 redfish_exporter:latest

Legacy way

mkdir /srv/redfish-exporter

Python dependencies

cd /srv/redfish-exporter
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Create user

sudo useradd -r -s /bin/false redfish

Install systemd unit file

sudo cp redfish-exporter.service /etc/systemd/system/redfish-exporter.service
sudo systemctl daemon-reload
sudo systemctl enable --now redfish-exporter.service

Usefull oneliners

public IP with curl

curl icanhazip.com
curl -4 icanhazip.com
curl -6 icanhazip.com

curl 'https://api.ipify.org?format=json'
curl 'https://api64.ipify.org?format=json'