There's nothing pleasant about the data corruption or even hardware damage that can result from a power failure. Carla Schroder explores how UPS units and a couple of Linux UPS tools can help safeguard your mission-critical computers.
Power failures are a fact of life, and as diligent, conscientious network admins, we implement whatever power backups we can wrangle funding for. A number of bad things can happen with a sudden power interruption: data corruption, mangled file systems, and even hardware damage. At the very least, we need to give important systems a chance to shut down gracefully, and then start back up when the power returns.
This is exactly what a UPS – uninterruptible power supply – is designed for. The term "uninterruptible power supply" is a bit misleading, though, as there are actually two types of UPS: lower-cost models that provide a battery backup and higher-end models that supply power continuously. The lower-end products, which used to be called "SPS" (standby power supply) units, provide a battery backup that activates during a power interruption.
The higher-end models, on the other hand, supply power continuously, and are truly "uninterruptible." They also "condition" the power, smoothing out sags and spikes. The electricity that comes out of our outlets is rather grotty — it isn't the nice, clean, carefully controlled voltages that computers prefer; rather it arrives in lumps and bumps. While mostly unnoticed by the casual user, even little tiny sags and surges in electricity take their toll over time. A true UPS costs 50-100% more than its SPS cousins, and the batteries must be replaced more often.
Whatever type of UPS you decide to use, it will only be good for running a system for a limited period of time. Some of the high-end models claim up to 90 minutes, but 10-15 is more typical. Their most important feature, in my not-so-humble-opinion, is being able to perform a graceful, unattended shutdown.
All UPS units come with nice Windows software for doing this. Some even provide Linux management and configuration software, though as usual, beware of binary-only drivers; useless old, moldy drivers; and drivers restricted to specific Linux distributions. (Hint to vendors: time did not stop the day Red Hat 6.0 was released.)
Page 2: Linux-Friendly UPS
Tripp Lite, APC, and Minuteman all provide some Linux software bundles, but not for all of their products. As usual, heroic persons in the Linux world have risen to the occasion to fill in the gaps. Here are a couple of Linux projects that should meet your needs.
Apcupsd is a great project for APC products. It works best when used with newer APC devices over a USB interface, and when run on newer Linux distributions, although it does also support older, serial-port APC UPS models.
Apcupsd comes in RPMs, source tarballs, and is also in Debian's repositories, so a simple 'apt-get install apcupsd' will fetch and install it.
Some of the so-called Linux drivers supplied by vendors are little more than dumb signal interfaces — all they know to do is how to switch to battery, and then shut the system down after so many minutes, even for UPS units with "smart" capabilities. Or they expect the Linux PCs will be monitored from a Windows server. As if!
Apcupsd, on the other hand, comes with a number of useful system monitors. All of the collected information is displayed on a nice, colorful HTML page, showing the current status for all of your UPS units. Useful information like online status, charge level, load level, and battery run time is displayed on the Apcupsd status page.
Apcupsd also does "slave" shutdowns. When there is more than one PC connected to a UPS, only the "master" PC needs to be connected via the USB or serial cable, and only that computer needs to have the drivers and management software installed. The slave machine runs a monitoring daemon that responds to any shutdown command from the master.
The slave machines can be configured individually; I usually set them to shutdown quickly, to save battery power for the master. (Note: I use "master" and "slave" for consistency with the Apcupsd documentation. You are welcome to call them anything you want.)
You can also turn any networked computer into a slave using NIS. (Obviously this has little utility if the PC is not connected to a UPS.) This lets you use any NIS server as the master.
The Apcupsd site provides a wealth of documentation, including wiring diagrams should you need to make your own cables.
Page 3: Network UPS Tools (NUT)
Network UPS Tools (NUT)
The NUT project supports a wide variety of UPS brands; here is a partial list:
- APC Smart-UPS, Back-UPS Pro, Matrix-UPS models
- Belkin Regulator Pro
- Old Best Power Fortress hardware
- Energy System
- ETA UPS hardware with the "PRO" smart mode
- Fenton Technologies
- Powerware/Best Power
- Tripp Lite
Again, there are nice Debian packages in addition to the usual tarballs; simply install the 'nut' package. NUT is targeted more for network client-server, but it does fine for standalone systems as well. NUT supports mostly serial-port UPS, with a little bit of experimental USB thrown in.
Do not despair if neither NUT nor Apcupsd specifically lists your particular UPS. First, try a driver for similar models; if that doesn't help, NUT has a number of general-purpose drivers that are worth trying. Even though there are many brands, there are a limited number of protocols that are used.
Starting Up After a Shutdown
Usually all you need to make this work is to have it enabled in the system BIOS. (It's usually off by default.) Both NUT and Apcupsd run as daemons, and will start up automatically after bootup.
Smart and Dumb UPS
A $50 UPS isn't going to have all kinds of advanced management circuitry, and it also won't be able to use the many advanced features of Apcupsd and NUT. It will only do two things: switch to battery power when needed and send a signal to the PC that it's time to shutdown. This however is 'Good Enough' for many users — it sure beats the heck of out waking up to confused file systems and fried drives.
Sneaky Cable Gotchas
As usual, some manufacturers think we will be happier customers if they sell us overpriced, non-standard cabling. Make sure your units come with all the necessary cables, and be careful to keep them matched up to the correct devices. (OK, there may be a reasonable technical reason to put custom pinouts in a USB or serial cable. Sure.)
Most UPS are designed so that users can easily replace the batteries. On a standby-type unit, expect 4-6 years of battery life. On a true UPS, I replace them annually, because they are used on very important machines and work harder than normal, but they could probably go longer. Higher-end units have hot-swappable batteries, which is a lovely feature to have when you're looking at annual battery replacements.
Apcupsd home page
NUT home page
See All Articles by Columnist Carla Schroder