A Prometheus exporter for CyberPower UPS Linux daemon (pwrstat).
The Pwrstat Exporter enables Prometheus to monitor data from CyberPower Uninterruptible Power Supply (UPS) systems running on Linux. It uses the pwrstat Linux daemon for data acquisition.
Prerequisites Docker installed on your system.
Run the following command to install the Pwrstat Exporter using Docker:
docker run \
--name pwrstat-exporter \
--device /dev/bus/usb:/dev/bus/usb \
--device /dev/usb/hiddev0:/dev/usb/hiddev0 \
--privileged \
--restart unless-stopped \
-p 8088:8088 \
-d cardif99/pwrstat-exporter:latest
Alternatively, refer to the provided docker-compose.yaml for a Docker Compose setup.
Prerequisites
- Golang version 1.16 or higher.
Clone the repository and build the executable:
git clone https://github.com/kerwenwwer/pwrstat-exporter.git
cd pwrstat-exporter
go build && mv pwrstat-exporter /usr/local/bin/
The pwrstat
command requires sudo privileges:
sudo pwrstat-exporter
To specify arguments:
sudo pwrstat-exporter --web.listen-address 8088 --web.telemetry-path /metrics
Configuration
Create a systemd service configuration file at /etc/systemd/system/pwrstat-exporter.service
:
[Unit]
Description=pwrstat-exporter
[Service]
TimeoutStartSec=0
ExecStart=/usr/local/bin/pwrstat-exporter
[Install]
WantedBy=multi-user.target
Reload the systemd daemon, enable the service at startup, and start the service:
sudo systemctl daemon-reload
sudo systemctl enable pwrstat-exporter
sudo service pwrstat-exporter start
A custom Grafana dashboard is available for visualizing the data. Import the dashboard using the grafana-dashboard.json file.