A Prometheus exporter for CyberPower UPS Linux daemon (pwrstat)
1.4K
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
This use case demonstrates how to handle multiple UPS devices connected to the same machine.
services:
pwrstat_exporter_dev0:
image: corundex/pwrstat-exporter:latest
container_name: pwrstat-dev0
devices:
- /dev/bus/usb:/dev/bus/usb
- /dev/usb/hiddev0:/dev/usb/hiddev0
privileged: false
environment:
- ALARM=off
restart: unless-stopped
ports:
- 8088:8088
pwrstat_exporter_dev1:
image: corundex/pwrstat-exporter:latest
container_name: pwrstat-dev1
devices:
- /dev/bus/usb:/dev/bus/usb
- /dev/usb/hiddev1:/dev/usb/hiddev1
privileged: false
environment:
- ALARM=on
restart: unless-stopped
ports:
- 8089:8088
Same logs from the running container:
===========================================================================
Sat May 25 20:30:42 UTC 2024
===========================================================================
* Starting pwrstatd 1.4.1
...done.
===========================================================================
Setup configuration successful.
Alarm turned off.
Daemon Configuration:
Alarm .............................................. Off
Hibernate .......................................... Off
Cloud .............................................. Off
Action for Power Failure:
Delay time since Power failure ............. 60 sec.
Run script command ......................... On
Path of script command ..................... /etc/pwrstatd-powerfail.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On
Action for Battery Low:
Remaining runtime threshold ................ 300 sec.
Battery capacity threshold ................. 35 %.
Run script command ......................... On
Path of command ............................ /etc/pwrstatd-lowbatt.sh
Duration of command running ................ 0 sec.
Enable shutdown system ..................... On
===========================================================================
The UPS information shows as following:
Properties:
Model Name................... CP1350PFCLCD
Firmware Number.............. CRCA102_261
Rating Voltage............... 120 V
Rating Power................. 810 Watt
Current UPS status:
State........................ Normal
Power Supply by.............. Utility Power
Utility Voltage.............. 120 V
Output Voltage............... 120 V
Battery Capacity............. 100 %
Remaining Runtime............ 64 min.
Load......................... 72 Watt(9 %)
Line Interaction............. None
Test Result.................. Unknown
Last Power Event............. None
===========================================================================
Info: Serving metrics on http://localhost:8088/metrics
Content type
Image
Digest
sha256:932ca8f77…
Size
41.1 MB
Last updated
over 2 years ago
docker pull corundex/pwrstat-exporter