NUT and APC Smart UPS via Serial Port
NUT (Network UPS Tools) in SME 7.0 defaults to using a USB connection between the UPS and computer. My APC Smart UPS only has a serial connection, this is how I made NUT talk to my UPS using the APC supplied 940-0024C cable.
NUT already exists in the configuration database as a disabled service. It needs to be enabled and a couple of properties changed. I also used a symlink for the serial port to use rather than a direct connection to the device. The use of a symlink and thus the udev custom template is optional. Just use the relevant /dev/ttyS instead of /dev/apcups in the "config setprop nut Device xxx" command below.
How to do it
1) To adjust the configuration database issue the following commands as root:
config setprop nut Device /dev/apcups
config setprop nut Model apcsmart
config setprop nut status enabled
Note the case of "Device" and "Model".
To check that these changes have stuck use config show nut and you should get:
nut=service Device=/dev/apcups Model=apcsmart status=enabled
2) If using a symlink for the NUT Device, make a custom template so that udev creates this symlink on boot up.
Create the directory /etc/e-smith/templates-custom/etc/udev/rules.d/10-local.rules and change to it. Using your favorite text editor create a file called apcups so that it contains:
# For NUT and APC Smart UPS via Serial Port KERNEL="ttyS0", SYMLINK="apcups"
Changing "ttyS0" to the serial port that your UPS is connected to of course.
Expand the template expand-template /etc/udev/rules.d/10-local.rules. This is required as a seperate expansion as this template is not (yet!) known to SME Server.
3) Make SME Server fully aware of the changes by doing:
signal-event post-upgrade
signal-event reboot
When the server comes back up NUT should be running. Login to the server and try upsc ups@localhost, if all is well this will return loads of information about the UPS state. /var/log/messages is a good place to look for hints if things aren't working.
Finally
Feeling brave? Pull the power to the UPS and the server should gracefully shut down, I haven't felt brave yet...
This How To: can probably used a basis to get other serial port connected UPS's working with NUT. The man pages of the NUT suite are pretty good and NUT supports a large range of UPS's.
History
2006-5-2
First version. DL.
2006-5-3
Changed to using a custom template to generate the udev 10-local.rules file. At the time of writing 10-local.rules is not in the SME base distribution and is not templated but it could become so in the future. If it did any direct creation/edit of this file would be lost and with it the serial connection to the UPS. It would be very easy for this loss to go unnoticed until the power went out and the server didn't shutdown. Thanks to Greg J. Zartman for pointing this out and to Charlie Brady high lighting that the Device symlink is, in anycase, optional. DL.
2006-5-4
Thanks to Alex Schaft for telling me about /etc/sysconfig/ups. This is part of the basic server configuration stuff normally acessed via the admin console, except the admin console doesn't appear to have any NUT/UPS related pages... DL.