Prometheus exporter for CyberPower UPS. One command to install.
curl -fsSL https://raw.githubusercontent.com/simran2491/pwrstat-node-exporter/main/install.sh | sudo bashThat's it. The installer will:
- ✅ Download the exporter from this repo
- ✅ Install it to
/opt/pwrstat-node-exporter/ - ✅ Set up a systemd service
- ✅ Enable it to start on boot
- ✅ Verify metrics are working
curl -fsSL https://raw.githubusercontent.com/simran2491/pwrstat-node-exporter/main/install.sh | sudo bash -s -- --version v1.0.0- CyberPower UPS connected via USB
- PowerPanel for Linux installed (provides
pwrstatcommand) - Python 3 (usually pre-installed)
curl -fsSL https://raw.githubusercontent.com/simran2491/pwrstat-node-exporter/main/uninstall.sh | sudo bash| Metric | Description |
|---|---|
pwrstat_state |
UPS state (1=Normal, 0=On Battery, -1=Unknown) |
pwrstat_battery_capacity_percent |
Battery charge percentage |
pwrstat_remaining_runtime_minutes |
Estimated runtime on battery |
pwrstat_load_watts |
Current load in watts |
pwrstat_load_percent |
Load as percentage of capacity |
pwrstat_utility_voltage_volts |
Input voltage from utility |
pwrstat_output_voltage_volts |
UPS output voltage |
pwrstat_power_source |
Power source (1=Utility, 0=Battery) |
pwrstat_test_result |
Last self-test result (1=Pass, 0=Fail) |
pwrstat_last_power_event_info |
Last power event info |
Add to your kube-prometheus-stack Helm values:
prometheus:
prometheusSpec:
additionalScrapeConfigs:
- job_name: 'pwrstat-exporter'
scrape_interval: 30s
static_configs:
- targets: ['<NODE_IP>:9182']
labels:
instance: 'master-ups'Replace <NODE_IP> with your host IP (e.g., 10.0.0.219).
# Check service
systemctl status pwrstat-exporter
# View metrics
curl http://localhost:9182/metrics
# Logs
journalctl -u pwrstat-exporter -f# HELP pwrstat_state UPS state (1=Normal, 0=On Battery, -1=Unknown)
# TYPE pwrstat_state gauge
pwrstat_state 1
# HELP pwrstat_battery_capacity_percent Battery charge percentage
# TYPE pwrstat_battery_capacity_percent gauge
pwrstat_battery_capacity_percent 100
# HELP pwrstat_load_watts Current load in watts
# TYPE pwrstat_load_watts gauge
pwrstat_load_watts 127
A pre-built dashboard is included in this repo. Import it into Grafana:
- Go to Dashboards → Import
- Upload
grafana-dashboard.json - Select your Prometheus datasource
Dashboard features:
- UPS status, power source, and battery charge overview
- Real-time load and voltage time series
- Runtime, self-test, and power event panels
- Energy cost tracking (30-day bill, daily average, trend) at $0.10/kWh
Add to Prometheus stack:
additionalPrometheusRulesMap:
ups-alerts:
groups:
- name: ups_alerts
rules:
- alert: UPSOnBattery
expr: pwrstat_power_source == 0
for: 1m
labels:
severity: warning
annotations:
summary: "UPS running on battery"
- alert: UPSBatteryLow
expr: pwrstat_battery_capacity_percent < 20
for: 5m
labels:
severity: critical
annotations:
summary: "UPS battery at {{ $value }}%"
- alert: UPSHighLoad
expr: pwrstat_load_percent > 80
for: 10m
labels:
severity: warning
annotations:
summary: "UPS load at {{ $value }}%"# Service not starting
systemctl status pwrstat-exporter
journalctl -u pwrstat-exporter -f
# pwrstat not found
which pwrstat
sudo pwrstat -status
# Check metrics endpoint
curl http://localhost:9182/metrics
curl http://localhost:9182/healthLinux Host (UPS via USB) Kubernetes Cluster
┌──────────────────────┐ ┌──────────────────────┐
│ pwrstat CLI │ scrape │ Prometheus Server │
│ ↑ │◄───────│ :9182 │
│ pwrstat_exporter.py │ └──────────────────────┘
│ (systemd service) │
└──────────────────────┘
MIT
