In this tutorial, we use the function create_notification
, which sends the message according to the settings in the administration Foris, section Maintenance
Tutorial assumes, you have installed the apcupsd package
1) in replace the file /etc/apcupsd/changeme
with the following:
#!/bin/sh . /etc/apcupsd/apcupsd_mail.conf MSG="$HOSTNAME UPS battery needs changing NOW. " OUTPUT="${MSG} $(apcaccess status)" /usr/bin/create_notification -s error "${OUTPUT}" /usr/bin/notifier exit 0
2) in replace the file /etc/apcupsd/commfailure
with the following:
#!/bin/sh . /etc/apcupsd/apcupsd_mail.conf MSG="$HOSTNAME Communications with UPS lost. " OUTPUT="${MSG} $(apcaccess status)" /usr/bin/create_notification -s error "${OUTPUT}" /usr/bin/notifier exit 0
3) in replace the file /etc/apcupsd/commok
with the following:
#!/bin/sh . /etc/apcupsd/apcupsd_mail.conf MSG="$HOSTNAME Communications with UPS restored. " OUTPUT="${MSG} $(apcaccess status)" /usr/bin/create_notification -s error "${OUTPUT}" /usr/bin/notifier exit 0
4) in replace the file /etc/apcupsd/offbattery
with the following:
#!/bin/sh . /etc/apcupsd/apcupsd_mail.conf MSG="$HOSTNAME Communications with UPS restored. " OUTPUT="${MSG} $(apcaccess status)" /usr/bin/create_notification -s error "${OUTPUT}" /usr/bin/notifier exit 0
5) in replace the file /etc/apcupsd/onbattery
with the following:
#!/bin/sh . /etc/apcupsd/apcupsd_mail.conf MSG="$HOSTNAME Power Failure !!! " OUTPUT="${MSG} $(apcaccess status)" /usr/bin/create_notification -s error "${OUTPUT}" /usr/bin/notifier exit 0
6) restart APCUPSD
/etc/init.d/apcupsd restart