Wednesday, 13 June 2007

Network UPS Tools

A while ago I ranted about the installation of APC's Powerchute Network Shutdown for Linux. While I got it working, the 60Mb+ of memory footprint used by the Java VM always seemed ridiculous to me, specially for a daemon that doesn't do much more than wait for a shutdown command.

Today I needed those 67Mb of RAM because the kernel on an old-timer began oomkill'ing my processes. A quick search yielded NUT, that works just fine with the Network Management card of Smart-UPS 3000, using the SNMP module.

Here's what I did on the Debian machine.

1. Install packages nut and nut-snmp
# aptitude install nut nut-snmp
2. Create /etc/nut/ups.conf:
driver = snmp-ups
port = apc1.mydomain
desc = "APC1 UPS Network Management Card"
Notice that "port" is the hostname or IP of your APC network card.

3. Start the UPS driver to see if it is working:
# upsdrvctl start

Network UPS Tools - UPS driver controller 2.0.4
Network UPS Tools - Multi-MIBS SNMP UPS driver 0.41 (2.0.4)
Warning: This is an experimental driver.
Some features may not function correctly.

detected Smart-UPS 3000 RM on host apc1.mydomain
4. Create an empty upsd.users file for now:
 echo "" > /etc/nut/upsd.users
5. Create upsd.conf:
ACL all
ACL localhost

ACCEPT localhost
6. Start the server:
# upsd
Network UPS Tools upsd 1.5.12
Connected to UPS [apc1]: snmp-ups-apc1.mydomain
7. Run the upsc utility to test the daemon:
# upsc apc1@localhost ups.status
TRIM # OBS: Should have been "OL" but it seems Energy Australia wasn't cooperating.

# upsc apc1@localhost
battery.charge: 100.0
battery.charge.low: 120
battery.charge.restart: 30
battery.runtime: 840.0 snmp-ups
driver.parameter.mibs: apcc
driver.version: 2.0.4
driver.version.internal: 0.41
input.frequency: 050.0
input.sensitivity: 4
input.transfer.high: 253
input.transfer.low: 208
input.voltage: 250.0
output.current: 000.0
output.voltage: 221.0 230
ups.delay.shutdown: 180
ups.delay.start: 0
ups.firmware: 666.6.I
ups.load: 042.0
ups.mfr: APC 09/26/06
ups.model: Smart-UPS 3000 RM
ups.serial: JS0640013695
ups.status: TRIM
ups.temperature: 025.0
ups.test.result: 1
8. At this point it seems that all is working fine. Edit the upsd.users file:
password = mypass
allowfrom = localhost
upsmon master
9. Edit your upsmon.conf file and remember to set a MONITOR line:
MONITOR apc1@localhost 1 monuser mypass master
Check the examples for the other configuration directives.

10. Restart using the init script to make sure:
# /etc/init.d/ups-monitor restart
Restarting Network UPS Tools: upsdrvctl upsdrvctl upsd upsmon.
Check that the processes are running:
# ps auwx | grep ups
nut 22030 0.0 3.6 4540 2260 ? Ss 16:19 0:00 /lib/nut/snmp-ups -a apc1
nut 22032 0.0 1.1 1732 728 ? Ss 16:19 0:00 /sbin/upsd
root 22034 0.0 1.1 1724 680 ? Ss 16:19 0:00 /sbin/upsmon
nut 22035 0.0 1.2 1724 736 ? S 16:19 0:00 /sbin/upsmon
Have a look at the log files; they should look similar to:
# tail /var/log/syslog
Jun 13 15:52:08 localhost snmp-ups[22030]: Startup successful
Jun 13 15:52:08 localhost upsd[22031]: Connected to UPS [apc1]: snmp-ups-apc1.mydomain
Jun 13 15:52:08 localhost upsd[22032]: Startup successful
Jun 13 15:52:08 localhost upsmon[22034]: Startup successful
Jun 13 15:52:08 localhost upsd[22032]: Connection from
Jun 13 15:52:08 localhost upsd[22032]: Client monuser@ logged into UPS [apc1]
If that didn't work, have a look at your /etc/default/nut file - make sure the "START_" variables are set to yes.

I managed to get it running using NUT's install instructions. These are the basic things to get it running; I recommend reading the rest of the documentation to finish your set-up.

1 comment:

Anonymous said...

I have the same hardware setup as you. I was able to get NUT to work using your directions, but I have yet to figure out how to command the UPS to shut down prior to completely depleting the battery. My initial investigation into this suggests that it is not possible to command the UPS to shut down, due to limitations in the driver.

Were you able to command the UPS to power off? If so, what command did you use, and how did you incorporate it into the shutdown sequence of the NUT master?