Jeremy Herr's NUT UPS Page


Overview

Here are some notes on my configuration of a battery backup system on the computers in my office, using an American Power Conversion BackUPS Pro 1400, with the software package NUT version 1.2.0.

NOTE: If you use NUT like I did, one of your computers must be a unix machine!

How NUT basically works

There are three main components of NUT:

  1. Driver - operated by upsdrvctl
    This lives only on the main computer (server) that is connected to the UPS device via a signalling cable. It is the software interface to the UPS hardware.
  2. Server (a.k.a. Daemon) - operated by upsd
    This lives only on the main computer (server). It communicates with the driver and keeps track of the UPS status, and answers requests made by the clients (monitors)
  3. Client (a.k.a. Monitor) - operated by upsmon
    Each computer that is backed up by the UPS has a client (monitor) running on it. The client queries the server every 5 seconds asking what the status of the UPS is. If the monitor gets the response: "Utility power is down, switching to battery", it then shuts down its computer.

Equipment list and configuration


Here's how I hooked up my computers. vesuvio is connected to the UPS via a gray 940-0020B signalling cable (which looks like a RS-232 cable, but it's not). I purchased it for $35 from http://www.advancedpowr.com/. A regular RS-232 cable will not work. I believe the colors are important, that is, I understand that simple signalling cables are gray, whereas "smart" signalling cables are black, and regular RS-232 cables are tan. Each UPS model requires a particular signalling cable, so you should definitely check with APC before buying one. See my first attempt notes for more information.

Installation on one linux machine

First, I installed NUT on vesuvio only. I went to the web page, downloaded it and unpacked it with no problems. Then I followed the steps in the INSTALL file, referring to the README file as well as the man pages [1].

Build and Install walkthrough - these are margin notes for the directions in INSTALL

Steps 1 through 4 went just fine.

Step 5: I edited ups.conf to look as follows:

[upsvesuvio]
        driver = genericups
        port = /dev/ttyS0
        upstype = 2

Step 6: before typing /usr/local/ups/bin/upsdrvctl start, I found it was necessary to first type:
chmod a+r /dev/ttyS0
chmod a+w /dev/ttyS0

Step 7: No problems here.

Step 8: When starting the network server, /usr/local/ups/sbin/upsd, I got the error message:
Can't bind to socket: Address already in use
I ignored this and kept going. Supposedly it means that upsd is already running, but in any case, it doesn't matter.

Step 9: When you type /usr/local/ups/bin/upsc localhost, if you see the text STATUS: OL, then the UPS is using utility power (OL = OnLine) and things are working.

upsd/upsmon configuration walkthrough

OK, continuing through INSTALL...

Step 1: I edited upsd.conf to look like this:

ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32

ACCESS grant monitor localhost
ACCESS deny all all
The /32 means that 127.0.0.1 is an individual host. Other numbers like /27 correspond to whole networks. This configuration file defines localhost to be the local host, and grants it permission to monitor the status of the UPS.

Step 2: I edited upsd.users to look like this:

[admin]
	password = ADMINPASS
	allowfrom = localhost
	actions = SET
	instcmds = ALL

[monmaster]
        password = MASTERPASS
        allowfrom = localhost
        upsmon master

[monuser]
        password = USERPASS
        allowfrom = localhost
        upsmon slave
This file defines 3 "users", admin, monmaster and monuser. I believe for the 1-computer case that we are discussing here, monuser is unnecessary (but it doesn't hurt anything, and we might as well). allowfrom specifies the host that the user is allowed to log in from. upsmon master means that the computer will wait until the last possible moment (battery going critical) to shutdown, whereas upsmon slave means that the computer will shut down as soon as utility power goes down. At least, this is what I think happens. The NUT documentation is very unclear on this.

Step 3: I edited upsmon.conf to look like:

MONITOR upsvesuvio@localhost 1 monmaster MASTERPASS master      # I edited this
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/local/ups/bin/notifyme   # I added this
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC      # I added this
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC      # I added this
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC     # I added this
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC      # I added this
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC     # I added this
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC    # I added this
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC    # I added this
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC      # I added this
NOTIFYFLAG FSD SYSLOG+WALL+EXEC         # I added this
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

Steps 4 through 6: I had no problems with these

Step 7: I don't really understand what this is about. I haven't configured anything like they are talking about, and I haven't had any problems.

Setting up Sys V services

We're not quite done! Sure, we can manually start things by typing

% cd /usr/local/ups/
% bin/upsdrvctl start # start driver
% sbin/upsd           # start daemon
% bin/upsc localhost  # optional - gives UPS status
% sbin/upsmon         # start the monitor
...but we would prefer the computer do all this automatically whenever it is rebooted. It's not just a convenience, it's a necessity, because there could be multiple power outages when we aren't around to manually start things.

Well, in the directory /usr/local/ups/scripts/RedHat-6.0/ I found the scripts upsd, upsmon and upspowerdown, which I copied over into the directory /etc/rc.d/init.d/. Unfortunately, they don't work out of the box. Other than the obvious need to chmod a+x ups*, they need to be edited a bit, since they assume everything is in the current working directory, which is not the case.

I added ... mention prefix env var, and adding paths to everything

THIS DOCUMENT IS UNFINISHED!

Installation on one linux machine and 2 windows machines

more to come....

Footnotes

  1. [go there] To install the man pages, bash users should add the line
    export MANPATH=/usr/local/ups/man
    to their ~/.bashrc file, and then type
    . ~/.bashrc
    csh or tcsh users should add the line
    setenv MANPATH /usr/local/ups/man
    to their ~/.csh file and then type
    source ~/.csh
  2. [go there]
  3. [go there]