HOWTO: Using an APC Uninterruptible Power Supply with Linux
by
NorthBear

Another heavy, wet spring snow storm is moving through the mountains as I write this article. My APC Uninterruptible Power Supply (UPS) has actived 20 times this morning. Without it, my life would be miserable! Here is a nice HOWTO for setting up an APC UPS for Linux.

Typical APC UPS

The support package for APC UPS boxes is "apcupsd". The latest version is 3.14.0 and is available from APCupsd.org. Check the repositories for your Linux distro for the latest pre-compiled version, letting you avoid the bother of downloading and compiling the source code. The package also includes a GTK based GUI called "gapcmon" for monitoring the UPS.

After you install acpupsd, you will want to edit the daemon's configuration file to provide the name of the UPS, the cable type, connection type and battery level for automatic shutdown.

Here is what I changed in /etc/apcupsd/apcupsd.conf for my system:

Old New
            #UPSNAME
                 UPSNAME BE650R
            UPSCABLE smart
                 UPSCABLE usb
            UPSTYPE apcsmart                  UPSTYPE usb
            DEVICE /dev/ttyS0                  DEVICE
            BATTERYLEVEL 5
                 BATTERYLEVEL 20

I decided to initiate shutdown when the battery reaches 20% rather than the default 5% since I have a machine with two hard drives and a 24" LCD monitor to keep powered up.

Once you have configured acpupsd.conf, you will need to make certain the daemon is activated when the system boots up. Use the System Services tool supplied with your distro to activate the daemon. This figure shows the tool Kmenu->Administration->Server Settings->Services that is supplied with Fedora Core.

System Services ToolFig. 2 Activating apcupsd in Fedora Core


GAPCMON GUI Interface

I tend to activate the by GUI clicking on it in the Kmenu. It is possible to start the GUI automatically with a script in ~.kde/Autostart for KDE systems. You'll need to do some research to start it on a Gnome desktop. Two icons will appear in the system tray:

System Tray Icons
Fig. 3 Active Monitors Panel

The "UPS" icon provides access to the following setup panels:

Panel 1
Fig. 4 Active Monitors Panel

The GUI can monitor multiple apcupsd daemons, either locally or on remote machines using a LAN.

Preferences Panel
Fig. 5 Monitor Preferences Panel

The Preferences Panel allows you to control your various apcupsd monitors.

Graph Properties Panel
Fig. 6 Graph Properties Panel

The Graph Properties Panel allows the user to set the colors for the Historical Summary Graph. This is the first panel for the second tray icon, the one showing a power plug. The Glossary and About panels are text help files.

GTK APC Monitor Image 1Fig. 7 The Historical  Summary Graph

The Historical Summary Graph charts battery voltage, line voltage, percentage of time left and percentage of load on the UPS. While nice, this doesn't appear to be a terribly useful feature. It's more for Pointy Haired Bosses!

Detailed Information Panel
Fig. 8 Detailed Information Panel

The Detailed Information Panel has the "really good stuff". Timestamps for on/off battery, a cummulative time while on battery and the line voltage are very nice items to know. Too bad the battery isn't a "smart" one, otherwise we would know it's manufacture date.

Power Events Panel
Fig. 9 Power Events Panel

The Power Events Log shows line events and when the apcupsd daemon is shutdown.

Full Status Panel
Fig. 10 Full UPS Status Panel

The Full UPS Status Panel supplies even more information. Notice the "LOTRANS" and "HITRANS" values for dips and spikes in the line voltage.

Conclusion

The APC brand of Uninterruptable Power Supplys is not the only brand of UPS available. It is, however, the most widely available and has very good support under Linux in addition to Windows.

The only annoyance with the apcupsd package that I can remark upon is the rather odd fact that the default configuration file is setup for a UPS with a serial interface. While these were the standard 6 or 7 years ago, all the APC UPSs that I've purchased over the past few years have been USB interfaces. If the default configuration were changed to USB and some additional code was written to support automatically naming the UPS, then the manual editing of the configuration file could be eliminated. The less editing, the better!

I highly recommend that everyone get a UPS for their computers. It's a real lifesaver!