Acupsd is a really nice package, so this is just a suggestion for a small improvement. By default, acupsd emails me (i.e. system admin) on power outage, and when power returns. However, these emails have different subjects, and thus tend to get threaded separately, while ideally, events belonging together should thread together.
The easiest solution is through the scripts (/etc/acupsd/offbattery and onbattery) to record the message ID and set an appropriate References or In-Reply-To header in the emails. Here's my attempt, but this can probably be done more elegantly:
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the
# UPS goes back on to the mains after a power failure.
# We send an email message to root to notify him.
#
SYSADMIN=root
APCUPSD_MAIL="mail"
HOSTNAME=`hostname`
MSG="$HOSTNAME Power has returned"
if test -f /var/lib/apcupsd/$HOSTNAME.power; then LASTEVENT=`cat /var/lib/apcupsd/$HOSTNAME.power`
fi
#
(
echo "Subject: $MSG"
echo " "
echo "$MSG"
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -a "In-Reply-To: $LASTEVENT" -s "$MSG" $SYSADMIN
exit 0
==> /etc/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 email message to root to notify him.
#
SYSADMIN=root
APCUPSD_MAIL="mail"
Binary package hint: apcupsd
Acupsd is a really nice package, so this is just a suggestion for a small improvement. By default, acupsd emails me (i.e. system admin) on power outage, and when power returns. However, these emails have different subjects, and thus tend to get threaded separately, while ideally, events belonging together should thread together.
The easiest solution is through the scripts (/etc/acupsd/ offbattery and onbattery) to record the message ID and set an appropriate References or In-Reply-To header in the emails. Here's my attempt, but this can probably be done more elegantly:
#!/bin/sh apccontrol when the
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/
# UPS goes back on to the mains after a power failure.
# We send an email message to root to notify him.
#
SYSADMIN=root
APCUPSD_MAIL="mail"
HOSTNAME=`hostname` apcupsd/ $HOSTNAME. power; then
LASTEVENT= `cat /var/lib/ apcupsd/ $HOSTNAME. power`
MSG="$HOSTNAME Power has returned"
if test -f /var/lib/
fi
#
(
echo "Subject: $MSG"
echo " "
echo "$MSG"
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -a "In-Reply-To: $LASTEVENT" -s "$MSG" $SYSADMIN
exit 0
==> /etc/apcupsd/ onbattery <== apccontrol when the UPS
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/
# goes on batteries.
# We send an email message to root to notify him.
#
SYSADMIN=root
APCUPSD_MAIL="mail"
HOSTNAME=`hostname` "@$HOSTNAME> " apcupsd/ $HOSTNAME. power
MSG="$HOSTNAME Power Failure !!!"
MSGID="<"`date +%H%M%S`
echo $MSGID > /var/lib/
#
(
echo "Subject: $MSG"
echo " "
echo "$MSG"
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -a "Message-Id: $MSGID" -s "$MSG" $SYSADMIN