Cyberpower UPS Linux daemon (pwrstat) exporter for prometheus
  • Go 81.3%
  • Dockerfile 9.2%
  • Shell 5%
  • Makefile 4.5%
Find a file
Kuo Guang Tsai 0aa906f98c
Merge pull request #8 from boray-tw/main
Connection State Checking and Base Image Upgrade
2025-08-13 23:33:07 +08:00
.github/workflows Add docker image build for main 2024-04-12 17:07:10 +08:00
grafana Create grafana config folder 2024-04-12 16:47:14 +08:00
image update README.md 2021-07-30 23:23:53 +08:00
pwrstat Add testfile for pwrstat package 2024-04-10 17:40:57 +08:00
scripts fix: ensure a connected UPS before queries 2025-08-12 22:11:36 +08:00
.gitignore Update .gitignore and add test in github action 2024-04-10 18:47:07 +08:00
docker-compose.yaml refactor: reduced image size 2023-11-11 18:21:04 +01:00
Dockerfile fix: clean up powerpanel installer 2025-08-12 21:41:44 +08:00
go.mod Add testfile for pwrstat package 2024-04-10 17:40:57 +08:00
go.sum Add clean go.sum 2024-04-10 17:46:54 +08:00
LICENSE Create LICENSE 2021-07-06 18:47:49 +08:00
main.go Fix typo 2024-04-12 16:47:57 +08:00
Makefile Rename default DOCKER_TAG 2024-04-12 16:49:00 +08:00
README.md Update README.md 2023-11-22 23:34:42 +08:00

Pwrstat Exporter

A Prometheus exporter for CyberPower UPS Linux daemon (pwrstat).

Overview

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.

Docker Deployment

Prerequisites Docker installed on your system.

Installation

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.

Building from Source

Prerequisites

  • Golang version 1.16 or higher.

Installation

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/

Usage

The pwrstat command requires sudo privileges:

sudo pwrstat-exporter 

To specify arguments:

sudo pwrstat-exporter --web.listen-address 8088 --web.telemetry-path /metrics

Systemd Service Integration

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

Grafana Integration

A custom Grafana dashboard is available for visualizing the data. Import the dashboard using the grafana-dashboard.json file. grafana