How-To: Network your UPS

Got a couple of machines sharing a UPS? In today's How-To, we'll show you how to use your network to shut down all of the computers plugged into it and keep your precious data safe.





Edit /etc/default/nut with your favorite editor (example: sudo vi /etc/default/nut). Change the options to match above (i.e. no to yes).
Create and edit /etc/nut/ups.conf - (sudo vi /etc/nut/ups.conf)
The configuration is pretty simple. The compatibility list is a good place to start. Check the compatibility list to find out what driver/upstype to specify. For our APC BackUPS, it just the generic UPS driver, and we used serial port ttyS0.
It should look like this:
[deskups]
driver=genericups
port=/dev/ttyS0
upstype=2
Once that's configured, you can run upsdrvctl start to see if your UPS driver is working.
We had to do a quick chmod 777 /dev/ttyS0 command to get things going. If you have two serial ports, you may need to try using /dev/ttyS1 instead.
Create and edit /etc/nut/upsd.conf. (sudo vi /etc/nut/upsd.conf)
Our remote Windows box is located at ip address 10.0.0.57, change it to suit.
If you want to allow your local network, put in the network address (i.e. 10.0.0.0/24)
ACL all 0.0.0.0/0
ACL remote 10.0.0.57/32
ACL localhost 127.0.0.1/32
ACCEPT localhost
ACCEPT remote
REJECT all
Create /etc/nut/upsd.users. Put the following:
[monuser]
password = USERPASS
allowfrom = local
upsmon master
Create /etc/nut/upsmon.conf, add the following:
MONITOR ups-a-name-o@localhost 1 monuser USERPASS master
SHUTDOWNCMD "/sbin/shutdown -h +0"
replace MASTERPASS with your master password.

Click the Edit button next to the configuration file path.
In the first blank line, add the following
MONITOR deskups@10.0.0.10 1 upsmon USERPASS slave
deskups is the name of the UPS.
10.0.0.10 is the ip address of our Linux box.
The 1 says that 1 UPS must be running for the box to stay up.
USERPASS is the password from the upsd.users file.
slave tells the box to shut down ASAP so the master can shutdown first.
Save the file and close notepad.
Go back to the configuration tool and hit Apply and start WinNUT.

If you have a pair of Windows boxes you'd like to do this with, that's tough. Ok, we do have a few tricks: we've had good luck connecting GPS units up to multiple hosts serial ports just by wiring the ports together. You might be able to do a similar hack, but we haven't tested that one. So don't come crying to us if you break it.
Otherwise, that should be that. Let the rolling brownouts and blackouts begin!





















Reader Comments (Page 1 of 1)
x23 @ Jul 25th 2006 8:02PM
if you get a slightly newer UPS ... i think the Smart-UPS 700 is the cheapest with the "Smart Slot" you can get a network card for $279-ish and use the PowerChute Network Shutdown program to shutdown as many as you want.
granted it might be a toss up as to which is cheaper... the card or a random Linux machine. but i suppose if you were using the Linux machine anyway it's not an issue. if you weren't though... the space taken up by a Linux machine is definitely more than the network card inside the UPS.
there is a limit to how many machines you should be running on a small UPS anyway.
Network Shutdown :
http://nam-en.apc.com/cgi-bin/nam_en.cfg/php/enduser/std_adp.php?p_faqid=1141&p_created=1010390400
Network Cards :
http://www.apcc.com/products/family/index.cfm?id=98
Cheapest (new) UPS that has the Smart Slot :
http://www.apcc.com/resource/include/techspec_index.cfm?base_sku=SUA750&total_watts=50
thanks for posting this though... it reminded me i needed to order the network card with the temperature sensor.
Ken @ May 23rd 2007 8:57AM
The issue isn't how to run lots of computers on one UPS, it's how to cleanly shutdown systems on "dumb" UPS without serial/USB/Network connectivity. For example, I may have a mediaPC running on an APC UPC without signaling capabilities, and I may have a nice, server grade UPS in the basement for my file server/networking software, when the power goes out, everything stays on (server, networking, mediaPC), but the server can shut down cleanly while on battery, the mediaPC will simply wait to run out of power and die. With this setup, the mediaPC could detect a power problem and shut itself down.
Rob @ Jul 25th 2006 8:32PM
cool... anything for mac users?
cycomachead @ Jul 25th 2006 8:41PM
yeah how can I do this on a Mac?
Engadget, as far as these how-tos go, I love them. Though I don't understand everything (well in certain ones) (as I am only 13), I love them!
And the add a good touch of needed geekiness to this tech blog!
keep 'em up!
thecriticalanalysis @ Jul 25th 2006 9:07PM
I just hooked up two marine deep cycle batteries, you can find info on how to do this all over the net, or on my blog :)
IraqiGeek @ Jul 25th 2006 9:26PM
While its more expensive, one could use a gumstix, an older iPAQ flashed with Linux, or even a wrt access point flashed with openwrt or something similar. Then compile/install the ARM version of nut.
I'm not sure you'll find nut there, but Debian maintains an ARM repository of each of its releases. If its there, one could unpack the .deb package and install nut manually.
A small linux box that consumes very little power is far more efficient than using an entire PC only to send a simple trigger.
RacetrackOwner @ Jul 25th 2006 9:47PM
Bzzt. The correct solution:
http://www.homepowersystems.net/catalog.asp?prodid=472668
Fuzz @ Jul 25th 2006 9:57PM
The APC software can run a program on a power event, so you can just get it to run the shutdown command, as described here:
http://www.ss64.com/nt/shutdown.html
and shut down as many systems as you wanted. Much simpler, since you don't need Linux, or any other machines.
Chris @ Jul 25th 2006 10:00PM
bzzt to RacetrackOwner. still need a battery. generators don't include a battery so you still gotta have somehting on that pc till the generator gets reved up. also, a generator is a mechanical component, and mechanical things fail so you still will want some shutdown safety.
Paco @ Jul 25th 2006 11:04PM
I discovered my notebook has a built in UPS and it keeps the system up for 5-6 hours.
Actually I have a 2200va xlnet from apc with 1 extra battery and I don't bother shutting my machines down when the power goes out. I figure 6 hours should be long enough for them to get the power back on. :D
Mobile Reviewer @ Jul 26th 2006 2:51AM
good tutorial. will try to mount it with my UPS.
youngbeezer @ Jul 26th 2006 4:44AM
"I discovered my notebook has a built in UPS and it keeps the system up for 5-6 hours."
Yeah its called a battery...
teo @ Jul 26th 2006 7:45AM
"it's not for nothing that very decent UPS "
--> 'every decent UPS'
Cory Myers @ Jul 26th 2006 8:20AM
On UNIX and Windows systems (which is to say almost everything), `apcupsd` () works excellently for APC units. Here, we have a server and a desktop on one UPS; the server has a direct USB connection to the UPS, broadcasts the battery status to the desktop via the network.
Works very well.
Cory Myers @ Jul 26th 2006 8:21AM
The link to `apcupsd` in my above comment didn't come out, so here it is:
http://www.apcupsd.com/
Darth Poo @ Jul 26th 2006 9:46AM
Looks like we need to pull out the [sarcasm] tags around youngbeezer.
Jeanette Jackson @ Aug 9th 2006 7:57AM
We have a Backup UPS 500. Last year after all the hurricanes, the equipment started to make a funny noise. Now lately when we have power glitches, it does not work because the computer just shuts off. Could it be that the equipment needs a new battery? Where could I find a battery? Thanks.
ron @ Aug 9th 2006 11:49PM
I have gone one further having discovered nothing electrical works when the power fails... (I am elect eng in uk) I have a 1Kw apc ups with 2 100AH external auto batterys. this gives 3hrs runtime + to all eqipt tv dvd video fax ect. The computer has a separate 650w internal bat ups which gets supply from main 1Kw ups so after everything else stops the computer can run on for extra 25 mins before shutting down. If things get very bad and there is not at least 6-8 hrs power in 24
all I have to do is connect small generator to main ups
to charge batterys! you may think he is a nut remember me when you are in the dark.even if you do not go this far a ups on your computer & tv dvd is a must.
idl3mind @ Sep 11th 2006 11:04AM
to add to "10:00PM on Jul 25th 2006 by Chris", generators provide 'dirty' power. not only would you want the UPS for the switch-over interval, you also want the UPS for it's power filtering to continue to provide clean power to the equipment that is plugged into the UPS
Tilman @ Jan 19th 2007 1:56PM
Nut runs on Mac.
It has no problem with the UNIX side of your Mac, if you don't have any either. ;)
yefferson @ May 9th 2007 10:43AM
a want u.. halp me.... made to jurnal about UPS... place....