Wandering Thoughts archives


Some notes on what the CyberPower UPS 'Powerpanel' software reports to you

For reasons beyond the scope of this entry, I recently bought a reasonably nice UPS for home usage. Me being me, I then found a Prometheus metrics exporter for it, cyberpower_exporter (and see also Mike Shoup's blog post about it), and then tinkered with it. This exporter works by talking to the daemon provided by CyberPower's Powerpanel software, instead of talking directly to the UPS, so my first port of call was to dump the raw information the daemon was providing for my UPS.

(The Powerpanel software is available as a Fedora RPM that's not too obnoxious. Per the Arch Wiki page on CyberPower UPS, you can also use Network UPS Tools (NUT). I opted to take the simpler path that theoretically should just work.)

You get status information from Powerpanel by connecting to the Unix socket /var/pwrstatd.ipc (yes I know, it should be in /run) and sending ASCII 'STATUS' followed by two newlines. You can do this by hand with nc if you feel like it:

printf 'STATUS\n\n' | nc -U /var/pwrstatd.ipc

What you get back is something like this (this is my particular UPS model, yours may vary):

diagnostic_date=2020/07/31 12:34:53
power_event_date=2020/07/31 12:33:59
power_event_during=21 sec.

The 'volt' and 'watt' numbers need to be divided by 1000 to get the units you expect from their name. The 'load' is divided by 1000 to get a percentage (or by 100000 to get it in 0.0 to 1.0 form), and is as a percentage of the output rating watts. The daemon doesn't report the current load in watts; instead you have to compute it for yourself. The battery remaining time is in seconds. The battery capacity is a percentage, but unlike load, it's expressed as a straight 0-100 number. The times are in your local timezone, not UTC, and I don't know how the UPS reports longer durations of power events (in the minutes or even more than an hour).

I suspect that the state, power_event_result, and diagnostic_result fields can take on multiple values. Based on what the CyberPower pwrstat command reports for my UPS right now, these mean a normal state, that the last power event was a blackout (a total power loss), and that the last self-test passed.

(The blackout was because I unplugged the UPS from the wall socket to make sure everything worked, which is why it was so short.)

The reported load number is somewhat untrustworthy and definitely seems to be quantized by the UPS. It's possible to observe reported loads of '0' if my home machine environment is idle enough (with the display blanked). This isn't just an artifact of the Powerpanel software, either; when I looked at the UPS's actual front panel, it reported 0 load and 0 watts being used. The front panel also reports 'VA' figures, and they didn't go to zero at these '0 load' times. However, as far as I can tell VA figures aren't reported by the Powerpanel software, and may or may not be provided to the outside world by the UPS itself.

(The NUT page for a very similar model doesn't list any VA data.)

As a consequence, you can't really use the reported load value to see how much power your overall UPS-based setup is using over time; the UPS load will under-report at times of low usage and perhaps at other times. This was a bit disappointing, but then I didn't buy the UPS to (also) be a watt-meter with a USB readout that I could grab from the computer.

(The UPS connects to my desktop via USB and is visible as a USB device, but I haven't tried to dump its USB traffic to see the truly raw data. That's a little bit too much work for my current level of curiosity.)

linux/CyberPowerPowerpanelNotes written at 01:09:54; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.