Install a UPS (nut)

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 23:48, 25 August 2006 by Downlalaway (Talk | contribs) (Power outage detection)

Jump to: navigation, search

Connecting a UPS to your Linkstation (USB models)

Installing Network UPS Tools (nut)

NUT is a powerful tool for safely shutting down computers in a power cut. It can make a LS (or other embedded computer) attached to a usb UPS to be as effective as a full server UPS and shut down everything on your LAN if needed.


Install the 2.6 kernel to get the new USB HID modules

Setup your system to accept packages from the unstable branch (follow instructions for everything except the last step to "apt-get -t install xyz" )

Fix your localhost entry if applicable. This is a current bug with freelink 1.11 HG:

Modify /etc/hosts This line: Linkstation

to Linkstation localhost

if there was " localhost", this is good already, no need to change it.


apt-get -t unstable install nut nut-usb

which will also add the appropriate lib-usb. and install nut & nut-usb 2.0.4-2 or better

Config files setup

Now that you've installed nut, you must set it up. Follow instructions under /usr/share/doc/nut/README.Debian or use this quick and dry way:

cd /etc/nut/
cp  /usr/share/doc/nut/examples/ups.conf .
cp  /usr/share/doc/nut/examples/upsd.conf .
cp  /usr/share/doc/nut/examples/upsmon.conf .
cp  /usr/share/doc/nut/examples/upsd.users .
chown nut:nut *
chmod 600 *

ups.conf sets up the nut server and which driver to talk from the linkstation to the UPS by usb.

upsd.conf defines the IP address access groups e.g. localhost only or your LAN network.

upsd.users defines the user level (e.g. monuser,monmaster,admin) their passwords, IP address access and allowed actions to read or write to the UPS.

upsmon.conf gives the client program (upsmon) the login user, pass and shutdown behaviour for the particular machine.

Edit ups.conf

Add this anywhere inside the file:

       driver = newhidups
       port = auto
       pollinterval = 10
       desc = "My APC 1000 UPS":

Edit upsd.users

Add this anywhere inside the file:

       password  = blah
       allowfrom = localhost
       actions   = SET
       upsmon master

blah is the password you wish to use. Make sure you use the same one in upsmon.conf

Edit upsmon.conf

Add this line:

MONITOR myups@localhost 1 monuser blah master

blah is the password, which you should change to your own. Make sure you use the same one in upsd.users

Edit /etc/default/nut

Modify the first few lines to:

# start upsd
# start upsmon

Again: upsd is the server daemon which runs on the computer directly connected to the UPS. upsmon is the client which polls the server's upsd program to check status and shutdown the pc if needed. In this description server and client are both on the LS -which shuts itself down.

Issue a reboot

to load the newhisups driver, upsd and upsmon


Verify UPS connectivity

Basic connectivity

newhidups -u root -D -D -a apc

You should see your UPS information showing up.

tail -1000 /var/log/syslog |grep ups

You should see something like this: Aug 11 15:31:38 LinkStation newhidups[1606]: Startup successful Aug 11 15:31:38 LinkStation upsd[1607]: Connected to UPS [myups]: newhidups-auto Aug 11 15:31:38 LinkStation upsd[1608]: Startup successful Aug 11 15:31:38 LinkStation upsmon[1610]: Startup successful Aug 11 15:31:38 LinkStation upsd[1608]: Connection from Aug 11 15:31:38 LinkStation upsd[1608]: Client monuser@ logged into UPS [myups]

Disabling the Beeper or changing UPS variables

Wish to disable that beeper that wakes you up at night ?

upsrw myups@localhost

The ups.beeper.status variable is likely Enabled.

upsrw -s ups.beeper.status  myups@localhost
Username (root): monuser
Password: blah
Enter new value for  ups.beeper.status: 1
upsrw myups@localhost

Verify that ups.beeper.status now shows up as disabled Follow same method for changing other variables.

Power outage detection

If this all works, try removing power from your UPS to verify if the Linkstation will detect it. You should see this in your syslogs, again using

tail -1000 /var/log/syslog |grep ups

Aug 10 15:59:28 LinkStation upsmon[1613]: UPS myups@localhost on battery

Aug 10 16:04:39 LinkStation upsmon[1613]: UPS myups@localhost on line power

Powering other computers from the UPS

So far it should work before proceeding further -the LS will shut down when the power supply is off and the battery is low. The real power of NUT is that it can turn off lots of PCs including WinXX which are anywhere on your LAN even if they are only connected to "dumb" UPSes.

We need to set up a slave user, allow access from the LAN for it and then set up the clients. A slave user should shutdown before a master user.

Modifying the upsd server

Some changes on the LS (assumed upsd server): Modify upsd.users to add the slave user:

        password  = blah2
        allowfrom = mynet
        upsmon slave

"blah2" is another password to change to your own choice

Edit the upsd.conf to define the "mynet" group of IP addresses to have a bit as per:

ACL localhost
ACL mynet
ACL all
ACCEPT localhost mynet

Naturally, set to your subnet if different.

Setting up NUT and WinNUT clients

Now for the client machines, which can be linux boxes with NUT installed or a WinXX box with WinNUT ( ) located on the "mynet" IP range.

Upsmon is only needed so you only need to edit upsmon.conf (through the WinNUT Config tool):

MONITOR myups@linkstationip 1 monslave blah2 slave

For a linux box (well, debian at least) you'll need to only start the upsmon daemon via /etc/default/nut :

# start upsd
# start upsmon


Peter Selinger: Linux and the APC Back-UPS ES

Network UPS Tools (nut)