NUT with CyberPower UPS
-
@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.