Creating this solution began as an exercise in self-interest. I own a Belkin 6C550AVR UPS, and until a few months ago, I ran it with Belkin Sentry Bulldog for Linux. Unfortunately, when I upgraded to Fedora Core 6, I found that not only did Bulldog cease to function, but also there was no upgrade. What's more, I found that Belkin no longer supports Linux. And judging from Belkin's non-response to my inquiries, it seems they have no plans to change that policy.
So without UPS software, what I have is a functional but dumb UPS. That is, something that will not handle an automatic, safe shutdown in the event of a power outage. I had to find a replacement.
That replacement is called NUT, short for Network UPS Tool. In this Recipe, I'll explain how to install NUT and set it up. While this recipe is based on a Debian distribution, installation on rpm-based (Fedora, RHEL, etc.) distributions should work by using the automated installer packaged with your distro.
This Recipe is oriented toward UPS systems connected via USB. Setup for the old-style serial units is far easier and more predictable. If you choose that way, simply go to this MGE How-To page, and follow the instructions.
Also, while NUT can be used in an enterprise-class setup running many UPS systems and servers with automatic restoral of computer service, my ambition for this article is more limited. I simply cover workstation setup.
NUT UPS DRIVER AVAILABILITY:
NUT interfaces with your UPS through a driver. If you want to use a UPS with Linux—and no NUT driver exists for your UPS—you have to either find one that is supported or find someone to write a driver. You can use a UPS without a driver in "dumb mode"—you simply need to shut down the system when you know it's going to be unattended.
An online listing of NUT UPS drivers can be found here. There's also a list within the package (which is probably the most current list), but you can't access that list until after you install it.
Matching USB ID Codes: This is the final authority on what NUT will and won't run. But you can't do this until after you've downloaded and unpacked the source. You don't need to do that unless it not only fails from hotplug/udev, but won't even run as root (that is, you have troubleshooting to do). How to do this is described in the Udev section below.
HOW TO INSTALL NUT:
I now run the Debian Etch (testing) distribution of Linux. Debian has three official versions: stable, testing, and unstable. Stable (nicknamed Sarge) has been around long enough to be almost completely debugged. Testing is something of a work in progress, but is more likely to support the most current hardware. Finally, unstable (called Sid) is leading/bleeding edge. Etch is what the current "testing" distro is called, but soon it will be called "stable." Then, the "unstable" will become "testing."
Installing NUT is supported directly by the automated installation tool apt-get. It comes with several different front-ends; the one I use is called aptitude. If you can't use automated installation, I recommend downloading binaries from one of the Debian repositories for your version. You can find them here.
For other distributions, install the three apps in the in the command line below via automated installer for your distro, when possible. Otherwise, you can get NUT from source or packages for several distributions here and KNutClient here. (KNutClient is a display application for NUT, showing things like analog charge percentage meters, input voltage, etc.) Nut-usb is generated by the build script in a source build, so you don't have to get it separately. (Nut-usb is the software package that handles USB I/O, which is required if your UPS has a USB I/O.)
In this Recipe, the dollar sign ($) refers to any command you should run as user, and the hash mark (#) refers to any command you should run as root.
# aptitude install nut nut-usb knutclientYou can find the application package internal file list with the installed locations for any Debian dpkg-installed package (including apt-get) at /var/lib/dpkg/info/packagename.list. I'm not sure where it is for rpms, but if all else fails and you can't find where the rpm installation package put the executable files, do this:
# updatedbTake a coffee break, as this will require a few minutes.
# locate filenameThe updatedb command tells the computer to run the indexing program that the locate command uses to read the location of files from the database. AUTOMATED NUT SETUP: There is a NUT installation program called KNutSetting from the same developer as KNutClient. Unfortunately, it is not available via automated installer at this time. When I tried, both the distribution-specific binary and source build failed (a bug has been filed with the author). Someday, I hope, this program will be available, and it will do the work you must do manually, as described here. I mention KNutSetting so you can see if it's available yet. I hope the program will become available via automatic installer or downloadable binary by the time you read this Recipe. The easiest way to find out if it's available in a distro is to simply try and install it. If KNutSetting is available via Debian automated installation, simply open up a root login and:
# aptitude install knutsettingor if a downloadable binary, download from the above URL and:
# dpkg -i knutsettingNUT PRECONDITIONS: Does libusb exist on your machine? Check if you need to install libusb. Do this:
# ls /usr/lib/libusb* /usr/include/usb.h /usr/lib/libusb.a /usr/lib/libusb.so /usr/lib/libusb-0.1.so.4 /usr/lib/libusb.laIf it isn't installed:
# aptitude install lib-usb
and tell aptitude to install everything lib-usb .