update README.md

This commit is contained in:
2026-01-30 15:37:09 +01:00
parent 50e8376937
commit bdac561e86
2 changed files with 122 additions and 46 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 dasBaum
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,65 +1,114 @@
# Description
# Redfish Exporter
A Python-based Prometheus exporter for collecting power data (Watts, Volts, Amperes) from bare metal servers using the Redfish API. This tool supports multiple vendors (e.g., HPE, Supermicro).
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]
## Table of Contents
- [Redfish Exporter](#redfish-exporter)
- [Table of Contents](#table-of-contents)
- [Description](#description)
- [Features](#features)
- [Usage](#usage)
- [Installation](#installation)
- [Requirements](#requirements)
- [Configuration](#configuration)
- [Basic Configuration](#basic-configuration)
- [Basic Configuration](#basic-configuration-1)
- [Container](#container)
- [Legacy Installation](#legacy-installation)
- [Python Dependencies](#python-dependencies)
- [Create user](#create-user)
- [Systemd Service](#systemd-service)
- [Testet on Hardware](#testet-on-hardware)
- [License](#license)
---
## Description
This tool collects power metrics from servers using the Redfish API and exposes them in a format compatible with Prometheus. It supports both modern and legacy Redfish API versions and handles authentication for different vendors.
---
## Features
- Collects power metrics: Watts, Volts, and Amperes.
- Supports multiple vendors (HPE, Supermicro, etc.).
- Cross-platform compatibility (Linux and Windows).
- Graceful error handling and retry logic.
- Configurable via YAML.
- Docker support.
## Usage
```bash
usage: redfish_exporter.py [-h] [--config CONFIG] [--port PORT] [--interval INTERVAL]
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
-h, --help show this help message and exit
--config CONFIG Path to config file
--port PORT Override port from config file
--interval INTERVAL Override interval from config file
```
# Install
# Installation
## Requirements
Requirements:
Dependencies:
* Python 3.8+
* see `pyproject.toml`
* see requirements.txt
Install the dependencies using:
```bash
cd /srv/redfish-exporter
uv sync
source .venv/bin/activate
uv lock --upgrade --refresh
```
## Configuration
Create a `config.yaml` file with the following structure:
Create `config.yaml`:
### Basic Configuration
```yaml
---
interval: 5
port: 8000
username: user1
username: user
password: secret
chassis: ["1"]
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
- host1.example.net
- host2.example.net
- host3.example.net
- host4.example.net
```
or:
### Basic Configuration
```yaml
---
interval: 5
port: 8000
username: user1
password: secret1
chassis: ["1"]
hosts:
- fqdn: srv1-112.mgmt.wtb1.ch.abainfra.net
- fqdn: host1.example.net
username: user2
password: secret2
- fqdn: srv2-112.mgmt.wtb1.ch.abainfra.net
chassis: ["0"]
- fqdn: host2.example.net
username: user3
password: secret3
- fqdn: srv3-112.mgmt.wtb1.ch.abainfra.net
chassis: ["1"]
- fqdn: host3.example.net
username: user4
password: secret4
- fqdn: srv4-112.mgmt.wtb1.ch.abainfra.net
chassis: ["example"]
- fqdn: host4.example.net
username: user5
password: secret5
```
@@ -67,51 +116,57 @@ hosts:
The `port`, `interval` are optional and can be overwritten by argument. Save default values are hardcoded.
# Use as Container
# Container
To run the Redfish Exporter in a Docker container:
```
docker build -t redfish_exporter .
docker run -it --rm --name redfish_exporter_app -p 8000:8000 redfish_exporter:latest
docker buildx build -t your-tag .
docker run -it --rm --name redfish_exporter_app -p 8000:8000 your-tag:latest
```
# Legacy way
# Legacy Installation
```bash
mkdir /srv/redfish-exporter
# or
git clone https://github.com/dasbaum-ch/redfish-exporter.git /srv/redfish-exporter
```
## Python dependencies
## Python Dependencies
```bash
cd /srv/redfish-exporter
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uv sync
source .venv/bin/activate
uv lock --upgrade --refresh
```
## Create user
```bash
sudo useradd -r -s /bin/false redfish
```
## Install systemd unit file
## Systemd Service
1. Copy the systemd unit file:
```bash
sudo cp redfish-exporter.service /etc/systemd/system/redfish-exporter.service
```
1. Reload and start the service:
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now redfish-exporter.service
```
# Usefull oneliners
# Testet on Hardware
## public IP with curl
Here some Server's that I have successfully testet:
* Supermicro
* AS -5126GS-TNRT2
* Redfish 1.21.0
* AS -1124US-TNRP
* Redfish 1.8.0
* HPE
* ProLiant DL380 Gen10
* Redfish 1.6.0
```bash
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'
```
# License
This project is licensed under the MIT License. See the LICENSE file for details.