Apcupsd & email

I would like to know how I can get the apcupsd to send me an email in case of network failure.

The webinterface consists only of one entry under Packfire and one entry under Status Information.

An extra window shows the current status of the UPS.

I did not find anything in the Wiki either.

Thank you.

Most configuration has to be done from the shell.

APC UPS Daemon manual



different from APCupsd but for event of a network failure (and not power failure), you can use WIO (Who Is Online) which can warn if a change of state of a network device…

Email Notification of Events

It is possible to receive email notification of apcupsd events using some simple Visual Basic scripts contributed by Ed Dondlinger edondlinger@thepylegroup.com. The scripts are automatically installed in the etc/apcupsd directory of your apcupsd installation but are disabled by default. To enable them, first open them in a text editor such as Notepad and edit the USER VARIABLES section to set your email preferences including address, server information, etc. Then rename the script files without the *.example suffix. Scripts are supplied for onbattery, offbattery, and commfailure events. You can copy the scripts to other filenames and modify the email body text to respond to other events as described in Customizing Event Handling.


“the USER VARIABLES section” in which file?

The standard message scripts are written on the basis of a sendmail system being present. IPFire uses dma which requires a different format for the sending of the email.

I have been working on this for a while and have recently got a working process but have not yet had the time to update the wiki. That is next on my list of things to do.

In /etc/apcupsd/ there are the various communication scripts.

  • changeme
  • commfailure
  • commok
  • offbattery
  • onbattery

The following section in all of these

   echo "Subject: $MSG"
   echo " "
   echo "$MSG"
   echo " "
   /sbin/apcaccess status
exit 0

needs to be changed to

FROM="your from email address"
TO="your to email address"
echo From: $FROM
echo To: $TO
echo Subject: $MSG
echo " "
echo "$MSG"
echo " "
echo -ne $(echo "\r\n"; while read line; do echo "$line\r\n"; done < <(echo "$(/sbin/apcaccess status)"))
) | sudo -u nobody /usr/sbin/sendmail -t -f $FROM
exit 0

The “your from email address” and “your to email address” need to be changed to whatever email addresses you are using. In my case I used the same as I have entered into the Mail Service page of IPFire but I believe different ones should also work but I have not tried that out.

You can then test that it works by pulling the usb cable out of the UPS and after a certain time the commfailure script will be run. Then if after a while you plug the usb cable back in the commok message will be sent.


The cited topic is from the chapter " The Windows Version of apcupsd"
so it doesn’t help in a linux environment.

Something I forgot to mention.

The Mail Service menu page on the IPFIre WUI needs to be filled out, enabled and pressing the “Send test email” button needs to result in a successful receipt of an email before trying the changes to the apcups scripts.


“Send test email” is OK.

I have to play a bit with the times somehow the IPFire shuts down before it sends the mail in case of network failure.

I always have to send 2 emails but that is not a problem for me.

“UPS 1 The power supply has failed!”
Ok I get the message.

What I still need is “UPS 1 IPFire shutdown!” so I know that the IPFire is shutting down.
And “UPS 1 IPFire online” when the IPFire is up again.

I have selected “failing” and “loadlimit”.
But I will test this on Monday.

So scripts to do that are not part of the apcupsd package. So you will have to figure out how to write those scripts and how to link them to the apccontrol script.

I would recommend going in detail through the apcupsd manual which can be found on their website. Look in the “Customizing Event Handling” section.

1 Like

Alternatively, you can use ‘monit’…

This requires the installation of ‘monit’ as an additional addon.