[Nut-upsuser] NUT and CyberPower PR3000LCDRTXL2U

Stuart D Gathman stuart at gathman.org
Sun Aug 9 01:56:46 BST 2020


On Sat, 8 Aug 2020, Phil Stracchino wrote:

> (Actually, I wish I could set it by *low runtime*, not low charge.  What
> I'd really like to be able to do is tell it, "Shut down these
> non-essential servers if we've been on battery power longer than five
> minutes.  Shut down *everything* if remaining runtime drops below five
> minutes."  But I don't see any way to do that without writing the code
> myself.)

I've done the essentials of this by configuring upsmon differently on
essential and non-essential servers, and by using upssched.conf.

Here are some of the things you can do with upssched:

AT COMMBAD tripp at localhost START-TIMER upsreset 10
AT COMMOK tripp at localhost CANCEL-TIMER upsreset
AT ONBATT * EXECUTE sms-onbatt
AT ONLINE * EXECUTE sms-online

Not what you want, just illustrating the tools that can be scripted.

Here is a snippet from upssched-cmd:

case $1 in
     upsreset)
         logger -t upssched-cmd "The UPS has been gone for awhile,
resetting"
         echo "$TS" "NOCOMM" >>$LOG
         ;;
     sms-onbatt)
         logger -t upssched-cmd "Sending OnBattery SMS"
         echo "$TS" "SMS" \
                 "The Gathman Server has lost power and is on
battery.">>$LOG
         ;;
     sms-online)
         logger -t upssched-cmd "Sending OnLine SMS"
         echo "$TS" "SMS" \
                 "Power has been restored to the Gathman Server." >>$LOG
         ;;
     *)
         logger -t upssched-cmd "Unrecognized command: $1"
         ;;
esac

The $LOG file is watched (via inotify) by a process with different 
privileges than nut.  It sends sms and resets the braindead USB on UPS.

Also, early shutdown is easily accomplished for your non-essential
servers:

AT ONBATT * START-TIMER early-shutdown 2000
AT ONLINE * CANCEL-TIMER early-shutdown
AT ONBATT * EXECUTE onbatt
AT ONLINE * EXECUTE online

Late shutdown is done by setting LOW BATTERY shutdown to only set a timer,
which then starts the shutdown.

AT LOWBATT * START-TIMER late-shutdown 300

In ups.conf, you can override what the ups says for upsmon purposes:

[apc]
         driver = usbhid-ups
         port = auto
         serial   = "4B1717P20965"
         desc = "Back-UPS XS 1300G"
         vendorid = 051d
         override.battery.runtime.low = 300
         override.battery.charge.low = 15
         ignorelb

In upsmon.conf, you add EXEC flag to pass the events to upssched:

NOTIFYFLAG ONLINE       SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT       SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT      SYSLOG+WALL+EXEC



More information about the Nut-upsuser mailing list