NUT with CyberPower UPS
-
What about the issue (could just be related to CyberPower) that when the UPS shuts off due to running out of battery (all plugged in items power down) then immediately the UPS powers back on as if it decided "no wait, I do have a LITTLE more battery left. THis causes everything to turn BACK on only to be cut from power when the UPS ACTUALLY drains it's battery. How can I avoid this?
-
@bhjitsense That's going to vary from one UPS to another. Some UPS's can be told to shut off when some battery level is reached. Of course you will have to configured things to safe/power off at a level higher than that. Some UPS's will not power on (provide power to attached devices) after power is restored until the battery level reaches some value.
I do recall that NUT can tell a UPS to power down with some delay as the last thing before the service is stopped during a shutdown of the host machine. My recollection is fuzzy, google searching is required to nail down the specifics... I would have to pull the plug on mine to see what happens, I don't exactly remember if the UPS shuts off or just runs the battery down. Kids are home and in online class, not going to happen today...
Some threads here on that subject. Not going to wade into that today either...
-
@bhjitsense look for one of the variables in the UPS settings displayed on the UPS service in pfSense. Run your finger down the list and look for something related to load.off.delay. (it may not be exactly this as my memory is not great nowadays). If I remember correctly it defaults to 59 seconds which Cyberpower UPS doesn't recognize as a valid number so ignores it and thus the cause of your UPS suddenly powering off. Instead set it to something like 300 (5 mins) by adding an override statement in the extra settings sections of the UPS settings which is recognized by your UPS as a valid setting. So your extra settings should look like:
override.load.off.delay=300
save and restart the service. Test your new settings by going to shell and entering:
upsmon -c FSD
this will simulate a low battery situation and call the shutdown scripts. If your settings are correct your pfSense should have enough time to shutdown gracefully. If the UPS powers off before pfSense completes its shutdown then recheck your settings. If your pfsense shutdown ungracefully you might need to first boot into single user mode and fsck -F just to do a check on your volume before proceeding further.
Now, if your load on the UPS is greater than lets say 30% you might want to adjust the time when the UPS begins its shutdown by adding another line to the extra settings as such:
override.battery.low=50
ignorelbThe ignorelb is required if you want the above settings to take effect. Again I am not sure of my variable names so you will need to check the actual variable names listed in the UPS service on pfsense.
Like I said, the native apcsd daemon on pfsense is just much easier to use than NUT thus the reason I decided to purchase APC for my pfsense box. The Cyberpower has native drivers for Windows and Linux so I repurposed it to those boxes. You might want to consider the same.
-
@bhjitsense for your issue related to your UPS suddenly powering back up while still on battery I never solved that issue thus the reason I switched to APC.
I believe one of the settings controls that function but I never figured it out and since my systems are in production there is the possibility in future that something else will screw up and corrupt the pfsense box. My advice to you is that NUT and cyberpower don't get along well and since there are no native FreeBSD drivers I switched to APC. APC works exactly as predicted thanks to its native driver.
I wrote a shell script to overcome this failing and put it in CRON running every minute. I can't remember the command but I think it was upscmd -l which will list out the current settings of the UPS including battery levels. Pipe that into GREP and IF battery level < 50 call shutdown (upsmon -c FSD).
-
@bhjitsense correction: IF < 50 then poweroff
-
@bhjitsense if you really want to script the shutdown yourself something as simple as the following in CRON every minute will do the job:
upsc | grep 'OB' && poweroff
the above will gracefully shut down pfsense as soon as the system goes on battery.
if you want to shutdown on low battery
upsc | grep 'LB' && poweroff
but you will need to shut off NUT while still being able to query the UPS status so that you don't find yourself in competition with NUT issuing the shutdown command itself
-
@bhjitsense correction:
upsc <upsname> | grep 'OB' && shutdown
if you want to shutdown at a certain level then:
(( $(upsc <upsname> | grep 'battery.charge' | grep -oe '([0-9.]*)') < 60 )) && shutdown
will shutdown your firewall when battery level drops below 60%
-
I really appreciate your help @pppd! I can't believe I didn't realize I could just get the CRON package to make stuff like this.
I've considered switching to APC. Now that I know it has a native driver, i'll probably be pulling that trigger. -
@bhjitsense smart move with getting APC for pfsense (or freebsd for that matter). NUT is great and has hundreds of options but it needs to be correctly configured to work properly. Repurpose your cyberpower to Linux or Windows boxes which have native drivers.
-
@bhjitsense I notice a wrong bracket in the command...correction:
(( $(upsc <upsname> | grep 'battery.charge' | grep -oe '([0-9.]*') < 60 )) && shutdown
where <upsname> is the name of the UPS you entered in the UPS settings.
-
All this seems a bit overkill? jwj has a non hacky solution already with adding the flags to the driver section in the UI which he has personally tested to work.
My cyberpower UPS auto shuts itself down to protect its battery according to the documentation so shouldnt need a command to tell it to turn off, or have I misunderstood something?
-
@chrcoluk the solution is a stop/gap measure to deal with the cyberpower UPS suddenly coming back online while still on battery.
If you know all the commands of the cyberpower UPS please publish them so we don't have to use these hack methods.
-
I dont know any :(
Since none of my devices auto power on when power is restored I think I will be ok luckily.