Some settings you want to make to CyberPower's UPS Powerpanel daemon

October 31, 2020

I have a CyberPower UPS and a while back I installed their PowerPanel software to talk to it, in large part to get various status information in an automated way. The other day I discovered that it has some undesirable default settings. So here are some notes on things that you will almost certainly want to change in /etc/pwrstatd.conf if you're using PowerPanel too.

As I discovered, the daemon has at least two undesirable behaviors. It will power off your Linux system one minute after a power failure and then program the UPS to shut down all power ten minutes later, even if line power comes back in the mean time (if line power has come back, it at least turns back on ten seconds later). To disable shutdowns on power failure, the options I am using are:

powerfail-active = no
powerfail-shutdown = no

I suspect that the latter option is sufficient by itself, but the provided script doesn't do very much and I went for overkill. I think these can be set with 'pwrstat -pwrfail -shutdown off' and 'pwrstat -pwrfail -active off', but I edited the configuration file directly (partly because I was already looking at it to find things). There are similar settings for what to do when the battery gets low.

Programming the UPS to power off may only happen if you allow shutdowns on power failure (or general scripts), but I believe that you can specifically turn it off with some additional options:

# The UPS will turn power off when this time
# is expired.
shutdown-sustain = 0

turn-ups-off = no

The former may possibly be set with 'pwrstat -pwrfail -duration 0', but I'm not sure; the pwrstat help text is not clear and I'm not inclined to experiment. I don't think turn-ups-off can be changed through pwrstat. According to the help text comments in pwrstatd.conf, it looks like the equivalent of shutdown-sustain for low battery is the runtime-threshold setting, which also controls how little remaining runtime there is before your system triggers the script and starts shutting down.

My view on automated shutdowns is that if I'm in front of the computer during a power failure, I'm perfectly competent to shut it down when I determine that I need or want to do so. If I'm not in front of the computer, it can quietly run down the battery on its own in the hopes that the outage ends before the battery is exhausted.

As a side note, if you actually have an automated shutdown of your system when the UPS is running low, it's worth thinking about how the system is going to come back up when power returns. PowerPanel's 'have the UPS turn off power (then turn it back on)' has the advantage that it will restart machines that have been shut down, no matter what else happens, provided only that your BIOS is set to always power up when AC power appears (instead of being set to 'last state, whatever that was').

Comments on this page:

As a side note, if you actually have an automated shutdown of your system when the UPS is running low, it's worth thinking about how the system is going to come back up when power returns.

This would probably be a two-part procedure:

  • make sure the hardware has a 'restart after power loss' (BIOS/UEFI) setting that is enabled

  • bring down the OS to the halted state (halt(8)) instead of telling the kernel to power-off

You'd have to have the UPS 'blip' the system so that it resets and reboots: if one halts the system near the end of the battery run-time, but power is restored before it being drained, and so the UPS just keeps on going, that reset may not come. This may be why you had the following:

Second, the UPS itself counted down ten minutes and then shut all power off (turning it back on ten seconds later) […]

If your system had first halted (instead of powered-off), then this second step could have brought things up. Could this have been the intended use case for the situation that is described in your earlier post? If the power yo-yos for a bit then this always-power-off-and-reset strategy would have made sense, especially in a more "server" configuration versus a "desktop" one.

I'd curious to know the average duration of power outages are. I read somewhere that they tend to have a binomial distribution: either you're out for a few minutes or many hours. The IEEE has a definition which includes "momentary" (<5 minutes) and non-momentary outages. In the US events of the latter type are sent to the EIA for an annual report, e.g.:

By Gabriel A Devenyi at 2020-11-01 19:57:52:

Why not use apcupsd? Seems to support my CyberPower ups fine.

By terry at 2023-05-10 02:51:28:

apcupsd does not make it clear what happens when it sends the killpower command to the ups if the ups has utility power at the time it receives that command. would the ups actually power cycle as is required to have the computer, that has been shutdown due to the power outage, restart.

Written on 31 October 2020.
« A sysadmin learning experience courtesy of some UPS issues
A gotcha with combining single-label and multi-label Prometheus metrics »

Page tools: View Source, View Normal, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sat Oct 31 01:14:57 2020
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.