apcupsd to the rescue!

We had some fierce wind here today and a little after 10 this morning, the power went out. I had configured apcupsd to properly shut down the server, but I never actually tested it.

Setting up apcupsd was so straightforward, I didn’t even bother posting about it. Basically, you can install it using apt-get and configure it by editing /etc/apcupsd/apcupsd.conf.  The file has a simple layout and the comments are very helpful.

When I got home from work, I powered the machine (named governor) back on, checked /var/log/syslog and was happy to find this:

Feb 25 10:14:41 governor apcupsd[2350]: Power failure.
Feb 25 10:14:41 governor kernel: [1421562.103162] r8169 0000:00:0b.0: eth0: link down
Feb 25 10:14:41 governor kernel: [1421562.149510] usb 1-5: USB disconnect, address 2
Feb 25 10:14:47 governor apcupsd[2350]: Running on UPS batteries.
Feb 25 10:14:58 governor apcupsd[2350]: Reached run time limit on batteries.
Feb 25 10:14:58 governor apcupsd[2350]: Initiating system shutdown!

... more messages from various things shutting down ...

Perfect!  Oh wait — it was great that it shut down properly, but just this short part of the log tells an interesting story.

First

Feb 25 10:14:41 governor kernel: [1421562.103162] r8169 0000:00:0b.0: eth0: link down

My switch is not on a UPS, so eth0 lost its link. No biggie.

Second

Feb 25 10:14:41 governor kernel: [1421562.149510] usb 1-5: USB disconnect, address 2

The USB drive I’m using as a backup wasn’t plugged into the UPS. This is easily fixed.

Third

It powered off after only 10 seconds? That’s because I set TIMEOUT 10 in /etc/apcupsd/apcupsd.conf, thinking the value was in minutes. It says seconds right there in the helpful comments. Silly me. Fixed.

By the way, I set this timeout value on the assumption that if the power is out for more than 10 minutes, it’s probably going to be out for a while. This machine only serves two people, it is not critical that it stays up for a long as possible during a power outage.

Oh and just for reference, I check the status of the UPS with the apcaccess status command.

Also, ironically, these lines appear in the log just before the power failure:

Feb 25 08:52:26 governor apcupsd[2350]: UPS Self Test switch to battery.
Feb 25 08:52:34 governor apcupsd[2350]: UPS Self Test completed: Battery OK

It passed a self-test a little more than an hour before it got a real test.

This entry was posted in Linux and tagged , , . Bookmark the permalink. Follow any comments here with the RSS feed for this post. Both comments and trackbacks are currently closed.