Listing 5. /ect/apcupsd/onbattery

#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.  We send an e-mail message to root
# to notify him.
#
SYSADMIN=root
MAIL="bin/mail"
HOSTNAME=`hostname`
#
echo "HOSTNAME Power Failure" >/tmp/$$
echo " " >>/tmp/$$
/sbin/apcaccess status 2>>/tmp/$$
cat /tmp/$$ | $MAIL -s "HOSTNAME Power Failure !!!" $SYSADMIN
exit 0