Note: This page is incomplete. I will remove this when I have successfully completed configuring my UPS with NUT.
The power goes out all the time here, so I decided to take a shot at setting up a UPS and having the server shutdown when the power goes out. This turned out to be pretty difficult as the "Network UPS Tools" are a bit of a pain to set up. Here are my notes so far...
UPS's from Dell, MGE, and Eaton appear to be fully supported by NUT. Others should work, but if you can find one of those, it's guaranteed to work.
The ubuntu package is "nut":
$ sudo apt-get install nut
NUT is very painful to configure. Follow these steps carefully. The blasterspike.it link appears to be the best.
Identify UPS. lsusb works for USB connected UPS's. In my case, I have a "Cyber Power Systems CP1500AVR USB".
$ lsusb ... Bus 001 Device 003: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Check the NUT Hardware Compatibility List to figure out which driver will work for your UPS. For my USB UPS, the correct driver is "usbhid-ups".
Add a new section to /etc/nut/ups.conf for the ups. I picked "serverups" for the name. "ups" would probably be better for a simple setup like mine.
[serverups] driver = usbhid-ups port = auto desc = "Server UPS"
- Install udev rules for usbhid-ups (see man usbhid-ups INSTALLATION) sudo cp /lib/udev/rules.d/52-nut-usbups.rules /etc/udev/rules.d/ reboot - Set up /var/run/nut per http://www.blasterspike.it/2011/03/28/how-to-install-nut-on-ubuntu-10-10-maverick-meerkat/ sudo mkdir /var/run/nut sudo chown root:nut /var/run/nut sudo chmod 770 /var/run/nut - Test the ups.conf file: sudo upsdrvctl start Normal output: Network UPS Tools - UPS driver controller 2.6.3 Network UPS Tools - Generic HID driver 0.35 (2.6.3) USB communication driver 0.31 Using subdriver: CyberPower HID 0.3
- Launch upsd sudo upsd Normal output: Network UPS Tools upsd 2.6.3 listening on 127.0.0.1 port 3493 listening on ::1 port 3493 Connected to UPS [serverups]: usbhid-ups-serverups - Test the upsd with upsc sudo upsc serverups@localhost Should see values for a lot of variables.
- Continue with the blasterspike.it steps. They seem to be good. http://www.blasterspike.it/2011/03/28/how-to-install-nut-on-ubuntu-10-10-maverick-meerkat/ - upsd.users - Need to add a user id for upsmon to login. - upsmon.conf - Need to add a line to monitor the ups. - nut.conf - Set the mode. - Start it up at boot. blasterspike uses the old "service" to start this. Is upstart an option? It might be if we set it up ourselves. As it stands, initctl does not appear to know of it. See /etc/init.d/nut.
- Configure it to shutdown after 5 minutes instead of when the UPS goes critical. I don't see a way to do this anywhere. Strange. What exactly is its criteria for shutting down? 10% battery left? It's a UPS data item: battery.charge: 100 (percent) battery.charge.low: 10 (percent, this is when shutdown will occur) battery.charge.warning: 20 (percent) battery.runtime: 2887 (seconds) battery.runtime.low: 300 (seconds, this is when shutdown will occur) I think you can tweak this in one of the config files. There's an override. But this doesn't seem ideal. There's no way to say that it should shutdown after 5 minutes (if it can last that long).
How To Install NUT - Great article with all the steps.
Network UPS Tools - NUT
nut manual section 3.9 "One UPS, one computer. This is also known as "Standalone" configuration. This is the configuration that most users will use. You need at least a driver, upsd, and upsmon running."
5.2 "Configuration files are located in /etc/nut. nut.conf(5) must be edited to be able to invoke /etc/init.d/nut"
Section 6 of the docs covers setup. Basically, the ups.conf file has to have an entry for the ups. Then it will work. (If only that were it!)
Config files for NUT: nut.conf(5), ups.conf(5), upsd.conf(5), upsd.users(5), upsmon.conf(5)
http://archive09.linux.com/feature/128099 - Not sure this is any good.
Copyright (C) 2012, Ted Felix
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. See http://www.gnu.org/licenses/fdl.html for the full text of this license.
<- Back to my software page.Copyright ©2012, Ted Felix. Disclaimer