update README.md
This commit is contained in:
21
python/redfish-api/LICENSE
Normal file
21
python/redfish-api/LICENSE
Normal 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.
|
||||||
@@ -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.
|
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:
|
---
|
||||||
|
|
||||||
```
|
## Table of Contents
|
||||||
usage: redfish_exporter.py [-h] [--config CONFIG] [--port PORT]
|
- [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
|
Redfish Prometheus Exporter
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--config CONFIG Path to config file
|
--config CONFIG Path to config file
|
||||||
--port PORT Override port from config file
|
--port PORT Override port from config file
|
||||||
|
--interval INTERVAL Override interval from config file
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Installation
|
||||||
# Install
|
|
||||||
|
|
||||||
## Requirements
|
## 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
|
## Configuration
|
||||||
|
Create a `config.yaml` file with the following structure:
|
||||||
|
|
||||||
Create `config.yaml`:
|
### Basic Configuration
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
interval: 5
|
interval: 5
|
||||||
port: 8000
|
port: 8000
|
||||||
username: user1
|
username: user
|
||||||
password: secret
|
password: secret
|
||||||
|
chassis: ["1"]
|
||||||
hosts:
|
hosts:
|
||||||
- srv1-112.mgmt.wtb1.ch.abainfra.net
|
- host1.example.net
|
||||||
- srv2-112.mgmt.wtb1.ch.abainfra.net
|
- host2.example.net
|
||||||
- srv3-112.mgmt.wtb1.ch.abainfra.net
|
- host3.example.net
|
||||||
- srv4-112.mgmt.wtb1.ch.abainfra.net
|
- host4.example.net
|
||||||
```
|
```
|
||||||
|
|
||||||
or:
|
### Basic Configuration
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
interval: 5
|
interval: 5
|
||||||
port: 8000
|
port: 8000
|
||||||
username: user1
|
username: user1
|
||||||
password: secret1
|
password: secret1
|
||||||
|
chassis: ["1"]
|
||||||
hosts:
|
hosts:
|
||||||
- fqdn: srv1-112.mgmt.wtb1.ch.abainfra.net
|
- fqdn: host1.example.net
|
||||||
username: user2
|
username: user2
|
||||||
password: secret2
|
password: secret2
|
||||||
- fqdn: srv2-112.mgmt.wtb1.ch.abainfra.net
|
chassis: ["0"]
|
||||||
|
- fqdn: host2.example.net
|
||||||
username: user3
|
username: user3
|
||||||
password: secret3
|
password: secret3
|
||||||
- fqdn: srv3-112.mgmt.wtb1.ch.abainfra.net
|
chassis: ["1"]
|
||||||
|
- fqdn: host3.example.net
|
||||||
username: user4
|
username: user4
|
||||||
password: secret4
|
password: secret4
|
||||||
- fqdn: srv4-112.mgmt.wtb1.ch.abainfra.net
|
chassis: ["example"]
|
||||||
|
- fqdn: host4.example.net
|
||||||
username: user5
|
username: user5
|
||||||
password: secret5
|
password: secret5
|
||||||
```
|
```
|
||||||
@@ -67,51 +116,57 @@ hosts:
|
|||||||
The `port`, `interval` are optional and can be overwritten by argument. Save default values are hardcoded.
|
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 buildx build -t your-tag .
|
||||||
docker run -it --rm --name redfish_exporter_app -p 8000:8000 redfish_exporter:latest
|
docker run -it --rm --name redfish_exporter_app -p 8000:8000 your-tag:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
# Legacy way
|
# Legacy Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir /srv/redfish-exporter
|
mkdir /srv/redfish-exporter
|
||||||
|
# or
|
||||||
|
git clone https://github.com/dasbaum-ch/redfish-exporter.git /srv/redfish-exporter
|
||||||
```
|
```
|
||||||
|
|
||||||
## Python dependencies
|
## Python Dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /srv/redfish-exporter
|
cd /srv/redfish-exporter
|
||||||
python3 -m venv venv
|
uv sync
|
||||||
source venv/bin/activate
|
source .venv/bin/activate
|
||||||
pip install -r requirements.txt
|
uv lock --upgrade --refresh
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create user
|
## Create user
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo useradd -r -s /bin/false redfish
|
sudo useradd -r -s /bin/false redfish
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install systemd unit file
|
## Systemd Service
|
||||||
|
|
||||||
|
1. Copy the systemd unit file:
|
||||||
```bash
|
```bash
|
||||||
sudo cp redfish-exporter.service /etc/systemd/system/redfish-exporter.service
|
sudo cp redfish-exporter.service /etc/systemd/system/redfish-exporter.service
|
||||||
|
```
|
||||||
|
1. Reload and start the service:
|
||||||
|
```bash
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable --now redfish-exporter.service
|
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
|
# License
|
||||||
curl icanhazip.com
|
This project is licensed under the MIT License. See the LICENSE file for details.
|
||||||
curl -4 icanhazip.com
|
|
||||||
curl -6 icanhazip.com
|
|
||||||
|
|
||||||
curl 'https://api.ipify.org?format=json'
|
|
||||||
curl 'https://api64.ipify.org?format=json'
|
|
||||||
```
|
|
||||||
|
|||||||
Reference in New Issue
Block a user