[Nut-upsuser] Email Alerts for Multiple UPSs with upssched
O'Shaughnessy, Mike
Mike.OShaughnessy at gd-ms.com
Tue Oct 31 16:45:55 UTC 2017
I'm running a single "nut-server" that monitors seven ups units.
In upsmon.conf:
MONITOR ups-1 0 <User> <Pw> master
MONITOR ups-2 0 <User> <Pw> master
MONITOR ups-3 0 <User> <Pw> master
MONITOR ups-4 0 <User> <Pw> master
MONITOR ups-5 1 <User> <Pw> master
MONITOR ups-6 1 <User> <Pw> master
MONITOR ups-7 0 <User> <Pw> master
NOTIFYCMD /sbin/upssched
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
In upssched.conf
CMDSCRIPT /bin/upssched-cmd
AT LOWBATT ups-1 EXECUTE ups-1-low
AT LOWBATT ups-2 EXECUTE ups-2-low
AT LOWBATT ups-3 EXECUTE ups-3-low
AT LOWBATT ups-4 EXECUTE ups-4-low
AT LOWBATT ups-5 EXECUTE ups-5-low
AT LOWBATT ups-6 EXECUTE ups-6-low
AT LOWBATT ups-7 EXECUTE ups-7-low
Upssched-cmd:
echo "upssched-cmd entry was $1"
case $1 in
ups-1-low)
/ws/tools/shutdownUps-1
logger -t upssched-cmd "UPS 1 low battery"
;;
ups-2-low)
/ws/tools/shutdownUps-2
logger -t upssched-cmd "UPS 2 low battery"
;;
ups-3-low)
/ws/tools/shutdownUps-3
logger -t upssched-cmd "UPS 3 low battery"
;;
ups-4-low)
/ws/tools/shutdownUps-4
logger -t upssched-cmd "UPS 4 low battery"
;;
ups-5-low)
/ws/tools/shutdownUps-5
logger -t upssched-cmd "UPS 5 low battery"
;;
ups-6-low)
/ws/tools/shutdownUps-6
logger -t upssched-cmd "UPS 6 low battery"
;;
ups-7-low)
/ws/tools/shutdownUps-7
logger -t upssched-cmd "UPS 7 low battery"
;;
Esac
Scripts like 'shutdownUPS-N' do this:
* Foreach linux box on the ups, log in and issue "shutdown -h now"
* Foreach VMWare server on the ups, log in and issue "/sbin/shutdown.sh && /sbin/poweroff"
Hope that helps!
Mike
From: Nut-upsuser [mailto:nut-upsuser-bounces+mike.oshaughnessy=gd-ms.com at lists.alioth.debian.org] On Behalf Of Garrett Michael Hayes
Sent: Tuesday, October 31, 2017 11:10 AM
To: nut-upsuser at lists.alioth.debian.org
Subject: [Nut-upsuser] Email Alerts for Multiple UPSs with upssched
Greetings Gentlebeings,
I have started deploying a number of NUT instances on Raspberry Pi machines (Raspbian Jessie) across my network. The purpose of these "nutcases" as we refer to them is to monitor the status of the UPSs supporting our network switching infrastructure and notify us of power and battery events via email. No shutdown or other actions are required.
Everything is going spiffy as all get-out so far. But now I'm running up against a configuration issue I don't quite know how to address.
Thus far each "nutcase" has been configured to monitor a single UPS. Now I want to deploy one to monitor three UPSs in a larger switch closet. Adding the additional UPSs to ups.conf and upsmon.conf is fairly straightforward. But I'm darned if I can figure out how to configure the email alerts to let me know WHICH UPS is the source of an event.
I'm using upssched as my NOTIFYCMD, and it in turn is calling a little shell script that reads the flag that's passed and sends an email. What I can't figure out is how (if there is a way) to determine the originating UPS. It seems that only the status flag makes it across to the shell script. Or at least if it's passing more than that, I don't know how to retrieve it.
I'm sure I must be missing something simple. Any thoughts/pointers would be appreciated!
Garrett Michael Hayes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20171031/72dfb815/attachment-0001.html>
More information about the Nut-upsuser
mailing list