NUT & CyberPower UPS
For the impatients: skip to the settings.
Not long ago my APC Back-UPS 700 started beeping at me randomly for no apparent reason. I replaced its battery to no avail. When one day the power cut out and I found the UPS completely shut down instead of feeding power from its supply, I knew it was time to get a replacement.
So I went and bought a CyberPower CP900, which I read was a good alternative brand to APC. Given my previous experiences I wanted to try out something new instead of sticking to the same hardware again.
The previous UPS was connected with an RJ50-USB cable to a server running the NUT monitor, with another server polling status data from it with the respective client. Hardware failures excluded, this system was working fine: why not replicate it with the CyberPower too? It’s supported by NUT with the same usbhid-ups
driver I used with the APC. Nice surprise: no more finicky RJ50-USB cables, but instead a plain USB-B connector.
The driver found the UPS straight away, I edited some configurations to reflect the new product name in the logs, and off we go. Smoke test (cutting power):
Happy for the new change, I kept working on something else. But after a few hours I noticed that the UPS section of my Grafana dashboard was showing no datapoints.
I SSH’d into the machine hosting the NUT monitor and quickly checked the status with upsc
. It thought on it for a moment, and then came up with Error: Data stale
.
Uhm… What?
It turns out that many CyberPower products reset the USB interface if a driver has not connected for 20s.
After some more fiddling I noticed that NUT was set to consider an UPS “stale” (e.g.: “Hey Mr. UPS, you haven’t spoke to me for a while. You know what? I’ll just silently assume that you’re dead and not tell anyone about that.”) after 15 seconds by default.
In order to get a CyberPower USB UPS to stay connected for more than a couple of minutes, you have to change the staleness settings in NUT to give them some headroom and the polling interval in the definition of the UPS itself.
NUT Settings
1 | [cyber1] |
The pollinterval
key may or may not be a needed change, but since in this configuration it works I see no harm in leaving it where it is.
1 | DEADTIME 25 |
All the other settings are either at their default values or not relevant to the disconnection problem.
It took me a while to find the right combination of settings, I hope I saved you some time & experimentation!
Credits: