home | tech | misc | code | bookmarks (broken) | contact | README


Apcupsd notes

Setup

Introduction

Having a UPS is helpful for power outages. But its battery just lasts about 15 minutes for most of the UPSes. If the outage lasts more than 15 minutes, your computer will die anyway.

UPSes are not there to provide infinite energy for your computer. They exist to allow you make a clean shutdown in time and prevent a corruption of your filesystem. Read the great Why power outages are bad for your data article for more information on UPSes and computers.

This short page will describe how to set up Apcupsd so you can shutdown safely your computer before the energy goes off. For information about how Apcupsd works and more information about UPSes and Apcupsd, check the References section.

Monitoring a USB-cabled UPS in NetBSD with Apcupsd

When you connect your UPS in NetBSD using a USB, it will probably appear in the system messages (NetBSD 5.0 and Back-UPS ES 600 here):

$ dmesg | tail -2
ugen0 at uhub3 port 1
ugen0: American Power Conversion Back-UPS ES 600 FW:820.x1d.D USB FW:x1d, rev 1.10/0.06, addr 2

After installing Apcupsd from pkgsrc, copy the startup script to the right directory:

# cp /usr/pkg/share/examples/rc.d/apcupsd /etc/rc.d/

And make it start automatically on system startup:

# echo apcupsd=yes >> /etc/rc.conf

By default, Apcupsd is configured to listen for serial devices. To make it connect to USB devices, edit the file in /usr/pkg/etc/apcupsd/apcupsd.conf (thanks to the Apcupsd page in Gentoo wiki page about that). Apply this patch against it, or take look at the patch and change your file manually.

After that, just start your daemon:

# /etc/rc.d/apcupsd start

Check if it is working:

$ ps ax | grep apc
 9938 ?     Ssl   0:00.32 /usr/pkg/sbin/apcupsd --kill-on-powerfail

Great, it runs! If it doesn't run, you can check the reason in the Apcupsd log file, in /var/db/apcupsd.events. To get status and other information for your UPS, use the apcaccess command.

References

Apcupsd
The website of Apcupsd.
Why power outages are bad for your data
Great that explains why power outages are bad, from the hardware side to the software side. Presents possible solution. Among them, acquiring a UPS.
Monitoring Your UPS With apcupsd
Outdated (2000!) article about apcupsd. Although many things are outdated (like the use of a serial, and not a USB connection), it is a good article that explains how apcupsd works internally.
Apcupsd page in Gentoo wiki
Very good page on how to setup apcupsd in Gentoo. It helped me with the configuration file.