feature: grouping
This commit is contained in:
@@ -1,76 +1,58 @@
|
||||
# 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).
|
||||
# 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) and is designed to run cross-platform on Linux and Windows.
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
|
||||
---
|
||||
I've createtd this python script to collect Power data to analyse Watts, Volts and Amperes. If there is a better solution or you want more feature, feel free to replace me or expand my prometheus exporter.
|
||||
|
||||
## Features
|
||||
- Collects power metrics: Watts, Volts, and Amperes.
|
||||
- Supports multiple vendors (HPE, Supermicro, etc.).
|
||||
- Supports grouping.
|
||||
- Cross-platform compatibility (Linux and Windows).
|
||||
- Graceful error handling and retry logic.
|
||||
- Configurable via YAML.
|
||||
- Docker support.
|
||||
|
||||
## Metrics Overview
|
||||
| Metric | Typ | Description |
|
||||
| ------------------------------------ | --------- | -------------------------------------------------------------- |
|
||||
| redfish_up | Gauge | Status from host (1 = reachable, 0 = not reachable). |
|
||||
| redfish_psu_line_input_voltage_volts | Gauge | Voltages per powersupply (label: host, psu_serial). |
|
||||
| redfish_psu_power_input_watts | Gauge | Watts per powersupply (label: host, psu_serial). |
|
||||
| redfish_psu_input_amps | Gauge | Amperes per powersupply (label: host, psu_serial). |
|
||||
| redfish_system_info | Info | Systeminformation (Vendor, Model, Serial, Redfish Version). |
|
||||
| redfish_request_latency_seconds | Histogram | Latency (label: host). |
|
||||
| redfish_errors_total | Counter | Number of errors per host and error type (label: host, error). |
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
usage: redfish_exporter.py [-h] [--config CONFIG] [--port PORT] [--interval INTERVAL]
|
||||
```
|
||||
usage: python main.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
|
||||
--interval INTERVAL Override interval from config file
|
||||
-h, --help show this help message and exit
|
||||
--config CONFIG Path to config file
|
||||
--port PORT Override port from config file
|
||||
```
|
||||
|
||||
# Installation
|
||||
# Install
|
||||
|
||||
## Requirements
|
||||
Requirements:
|
||||
* just (optional)
|
||||
* python 3.8+
|
||||
* uv
|
||||
* see `pyproject.tom`
|
||||
|
||||
* Python 3.8+
|
||||
* see `pyproject.toml`
|
||||
|
||||
Install the dependencies using:
|
||||
Install the dependencies using `uv`:
|
||||
|
||||
```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` with following structure:
|
||||
|
||||
### Basic Configuration
|
||||
```yaml
|
||||
@@ -87,7 +69,7 @@ hosts:
|
||||
- host4.example.net
|
||||
```
|
||||
|
||||
### Basic Configuration
|
||||
### Advanced Configuration
|
||||
```yaml
|
||||
---
|
||||
interval: 5
|
||||
@@ -95,15 +77,18 @@ port: 8000
|
||||
username: user1
|
||||
password: secret1
|
||||
chassis: ["1"]
|
||||
group: development # set default group for all hosts
|
||||
hosts:
|
||||
- fqdn: host1.example.net
|
||||
username: user2
|
||||
password: secret2
|
||||
chassis: ["0"]
|
||||
group: production # use group for specific host
|
||||
- fqdn: host2.example.net
|
||||
username: user3
|
||||
password: secret3
|
||||
chassis: ["1"]
|
||||
group: stage
|
||||
- fqdn: host3.example.net
|
||||
username: user4
|
||||
password: secret4
|
||||
@@ -113,30 +98,43 @@ hosts:
|
||||
password: secret5
|
||||
```
|
||||
|
||||
The `port`, `interval` are optional and can be overwritten by argument. Save default values are hardcoded.
|
||||
The `port`, `interval` and `interval` are optional and can be be overridden by command-line arguments. Default values are hardcoded.
|
||||
|
||||
### Prometheus Configuration
|
||||
```
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
# Container
|
||||
scrape_configs:
|
||||
- job_name: "prometheus"
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
|
||||
- job_name: "redfish_exporter"
|
||||
static_configs:
|
||||
- targets: ["localhost:8000"] # Adjust to your config
|
||||
metrics_path: /metrics
|
||||
scrape_interval: 15s
|
||||
```
|
||||
|
||||
# Docker / Container
|
||||
To run the Redfish Exporter in a Docker container:
|
||||
|
||||
```
|
||||
docker buildx build -t your-tag .
|
||||
docker run -it --rm --name redfish_exporter_app -p 8000:8000 your-tag:latest
|
||||
docker buildx build -t redfish_exporter .
|
||||
docker run -it --rm --name redfish_exporter_app -p 8000:8000 redfish_exporter:latest
|
||||
```
|
||||
|
||||
# Legacy Installation
|
||||
|
||||
## Python Dependencies
|
||||
```bash
|
||||
mkdir /srv/redfish-exporter
|
||||
# or
|
||||
git clone https://github.com/dasbaum-ch/redfish-exporter.git /srv/redfish-exporter
|
||||
```
|
||||
|
||||
## Python Dependencies
|
||||
```bash
|
||||
cd /srv/redfish-exporter
|
||||
uv sync
|
||||
source .venv/bin/activate
|
||||
uv lock --upgrade --refresh
|
||||
uv sync --locked
|
||||
```
|
||||
|
||||
## Create user
|
||||
@@ -145,28 +143,25 @@ sudo useradd -r -s /bin/false redfish
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
2. Reload and start the service:
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now redfish-exporter.service
|
||||
```
|
||||
|
||||
# Testet on Hardware
|
||||
|
||||
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
|
||||
|
||||
# License
|
||||
This project is licensed under the MIT License. See the LICENSE file for details.
|
||||
This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
# Testet on Hardware
|
||||
Here some Server's that I have successfully testet:
|
||||
|
||||
| Vendor | Model | Redfish Version |
|
||||
| ---------- | -------------------- | --------------- |
|
||||
| Supermicro | AS-5126GS-TNRT2 | 1.21.0 |
|
||||
| | AS-1124US-TNRP | 1.8.0 |
|
||||
| HPE | ProLiant DL380 Gen10 | 1.6.0 |
|
||||
|
||||
Reference in New Issue
Block a user