If anyone is interested in getting e-mail notifications on change of state of a UPS, then the steps I followed to get this working on my system are given below. There are other contribs that discuss how to set up nut (the UPS subsystem) and these instructions just concern the monitoring and reporting of nut.
1. Update the 'notify stub script'. This stub appears to be part-complete, so we will finish it off. Edit the file and copy the code content into it.
# vi /sbin/e-smith/nutUPS.notify
#! /bin/sh
# UPS notify script.
/bin/mail -s "UPS '$UPSNAME': $NOTIFYTYPE" admin <<END
$*
END
It should be noted that this script may get over-written in future SME versions. It is not templated, so I have no control over that. The fact that the current stub does not produce a message body, could be considered a bug. I have not raised anything in the bug tracker for this, and will leave it for others to decide.
2. Set up notification events. A custom template adds these into the upsmon.conf fie.
# mkdir -p /etc/e-smith/templates-custom/etc/ups/upsmon.conf
# vi /etc/e-smith/templates-custom/etc/ups/upsmon.conf/NOTIFYEVENTS
# Events to notify
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT SYSLOG+EXEC
NOTIFYFLAG COMMOK SYSLOG+EXEC
NOTIFYFLAG COMMBAD SYSLOG+EXEC
NOTIFYFLAG REPLBATT SYSLOG+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
# expand-template /etc/ups/upsmon.conf
Each of these events will produce a system log line and an e-mail to the administrator. There are other events you may wish to catch - see the manual page for upsmon for the full list.
3. Restart the nut process:
# /sbin/e-smith/service nut restart
Now pull out the mains cable, disconnect the serial/USB cables, turn the UPS off (assuming that does not cut the power to your server) etc. and see what happens.
Hope that is of some help.
-- JJ