NUT

Network UPS Tools (NUT) on Ubuntu

September 25th, 2006

NUT is a handy system for monitoring almost any UPS. Unfortunately the configuration process is tweaky and the included documentation is minimal and cryptic.

Here is a process that worked for me:

(Adapted from Engadget)

Open the Synaptic Package Manager (under the System->Administration menu) and search for ‘nut’. Select the package for installation and click on Apply.
Now log in as the superuser, then create and edit five configuration files:

sudo su

1: /etc/default/nut

nano /etc/default/nut

Change this:

# start upsd
START_UPSD=no

# start upsmon
START_UPSMON=no
to this:

# start upsd
START_UPSD=yes

# start upsmon
START_UPSMON=yes
(Ctrl-x, then y to exit and save)

2: /etc/nut/ups.conf

nano /etc/nut/ups.conf

The configuration is pretty simple. Check the compatibility list to find out what driver/upstype to specify. For my APC SmartUPS, I used the apcsmart driver, and serial port ttyS0:

[ups1]
driver=apcsmart
port=/dev/ttyS0

(Ctrl-x, then y to exit and save)
to test:

upsdrvctl start

I got this message:

Unable to open /dev/ttyS0: Permission denied

Current user id: nut (120)
Serial port owner: root (0)
Serial port group: dialout (20)
Mode of port: 0660

To resolve it permanently, a quick workaround is to add nut to the dialout group in Users and Groups (under the System->Administration menu).

Now test again:

upsdrvctl start

and I got:

Detected SMART-UPS 1000 [WS9730021313] on /dev/ttyS0

now stop upsdrvctl:

upsdrvctl stop

Done with that!

3: /etc/nut/upsd.conf

nano /etc/nut/upsd.conf

If you want to allow your local network, put in the network address (i.e. 10.0.1.0/24)

ACL all 0.0.0.0/0ACL remote 10.0.1.0/24

ACL localhost 127.0.0.1/32ACCEPT localhost

ACCEPT remote

REJECT all

(Ctrl-x, then y to exit and save)

4: /etc/nut/upsd.users

nano /etc/nut/upsd.users

Add the following:

[monuser]

password = changeme

allowfrom = local

upsmon master

(replace changeme with a good password)

5: /etc/nut/upsmon.conf

nano /etc/nut/upsmon.conf

Add the following:

MONITOR ups1@localhost 1 monuser changeme master
SHUTDOWNCMD "/sbin/shutdown -h +0"

(replace changeme with the good password you used in step 4)

Now start the service:

 /etc/init.d/nut start

and test the settings:

upsc ups1@localhost

You should get a slew of readings and settings from the ups:

battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 00
battery.date: 07/24/97
battery.packs: 000
battery.runtime: 2640
battery.runtime.low: 120
battery.voltage: 27.74
battery.voltage.nominal: 024
driver.name: apcsmart
driver.parameter.port: /dev/ttyS0
driver.version: 2.0.3
driver.version.internal: 1.99.7
input.frequency: 60.00
input.quality: FF
input.sensitivity: H
input.transfer.high: 132
input.transfer.low: 103
input.transfer.reason: S
input.voltage: 119.6
input.voltage.maximum: 120.2
input.voltage.minimum: 119.6
output.voltage: 119.6
output.voltage.target.battery: 115
ups.delay.shutdown: 020
ups.delay.start: 000
ups.firmware: 60.9.D
ups.id: UPS_IDEN
ups.load: 033.2
ups.mfr: APC
ups.mfr.date: 07/24/97
ups.model: SMART-UPS 1000
ups.serial: WS9730021313
ups.status: OL
ups.temperature: 029.7
ups.test.interval: 0
ups.test.result: NO
root@ubuntusrv:/etc# upsc ups1@localhost
battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 00
battery.date: 07/24/97
battery.packs: 000
battery.runtime: 2700
battery.runtime.low: 120
battery.voltage: 27.74
battery.voltage.nominal: 024
driver.name: apcsmart
driver.parameter.port: /dev/ttyS0
driver.version: 2.0.3
driver.version.internal: 1.99.7
input.frequency: 60.00
input.quality: FF
input.sensitivity: H
input.transfer.high: 132
input.transfer.low: 103
input.transfer.reason: S
input.voltage: 120.2
input.voltage.maximum: 120.2
input.voltage.minimum: 119.6
output.voltage: 120.2
output.voltage.target.battery: 115
ups.delay.shutdown: 020
ups.delay.start: 000
ups.firmware: 60.9.D
ups.id: UPS_IDEN
ups.load: 033.2
ups.mfr: APC
ups.mfr.date: 07/24/97
ups.model: SMART-UPS 1000
ups.serial: WS9730021313
ups.status: OL
ups.temperature: 029.7
ups.test.interval: 0
ups.test.result: NO

Another test: Push and hold the test button on the smartups, or briefly unplug the ups from the wall. You should see messages pop up in the terminal window:

Broadcast Message from nut@ubuntusrv
(somewhere) at 13:58 …

UPS ups1@localhost on battery

Broadcast Message from nut@ubuntusrv
(somewhere) at 13:58 …

UPS ups1@localhost on line power

It is working!

To add a windows client, download and install WinNUT.

At the configuration tool,you can leave everything at the defaults. All you need to do is edit the configuration file. (Click the Edit button to the right of the Configuration File Path).

Enter the same line as in upsmon.conf, changing localhost to the actual IP address of the ubuntu machine, and use ’slave’ instead of ‘master’:

MONITOR ups1@10.0.1.105 1 monuser changeme slave

(replace changeme with the good password you used in step 4)

You should be good to go.

Leave a Reply