Installing NUT on CentOS

Getting a UPS (Uninterruptible Power Supply) has long been on my tech wish list, so that I could keep my network and logging server up and running during transient power outages. Fortunately, aside from a brief outage right after we bought our house three years ago, power has not been a problem, unlike when I lived in Uptown, with nearly monthly outages. Nevertheless, you never know when the power will go out, so a UPS is a good insurance policy.

So when I recently got the opportunity to pick up one for a steal, I took advantage. Like most UPS appliances, this one came with monitoring software to allow for managing the UPS, as well as safely shutting down a linked computer if the battery backup lost juice, but it was for Windows only. Since I wanted to attach this to my CentOS server, that would not do. Never fear, though, since there is a Linux application that fits the bill: NUT, or Network UPS Tools. Below, I talk about what I did to get it up and running on my server.

Setting it up was simple. For the most part, I followed the instructions laid out here, on how to set it up on CentOS 5.5. I used yum to install it (a simple sudo yum install nut was enough), and I was halfway there. On CentOS, the configuration files are installed at /etc/ups, so I went there to set everything up. My ups.conf file is pretty simple:


I set up upsd.conf to listen on localhost on all of the defaults, set up upsd.users with a default user, and used all of the defaults for upsmon.conf. I ran into one minor issue, though, when I tried to run it for the first time: the driver wouldn’t load.

Since my UPS is on USB, I followed the USB configuration for udev at the above link:

ln -s /lib/udev/rules.d/62-nut-usbups.rules /etc/udev/rules.d/62-nut-usbups.rules

However, when trying to do a udevcontrol reload_rules and udevtrigger, both failed. That’s because the proper commands for my version of CentOS are udevadm control –reload-rules and udevadm trigger. After that, success! Or, at least it appears to work; I haven’t done a test to run the battery down to see if it shuts down. Oh well, testing in production is fun.

Getting the monitoring up and running is one thing, but if something happens and it isn’t logged, does it really happen? Of course not. So next time will be part two: how I got UPS monitoring into Splunk.

Be Sociable, Share!

One Response

  1. […] Last time, I had set up my UPS monitoring software on my CentOS logging server. But I wanted more: what good is having a UPS if I can’t monitor things like voltage, battery charge, and load on an ongoing basis? Of course, the answer to this is to log to Splunk, which is what I ended up doing. […]