monit as Fix for APC Back-UPS CS-500

To fix the recent failure of Network UPS Tools on my APC Back-UPS attached to Debian Etch, I used a pragmatic approach:

  • The problem with a missing or changing USB device is fixed by udev providing a static device name.
  • The 2nd problem with a crashing newhidups driver is solved by monit.

Perhaps all this is no longer necessary after updating Debian or NUT, but monit is very straightforward and the USB problem is probably inherent and needs ongoing care.

Please find the details of this fix in the following lines.

udev in Debian provides the file /etc/udev/rules.d/010_local.rules for this kind of configuration:

BUS=="usb", SYSFS{serial}=="NB0123459689*", SYMLINK+="backups_cs500"

The serial identifier needs to match the one found in the output of lsusb -v.

The driver newhidups is failing quite frequently directly after booting up my system. I am not sure, if there is a race condition (nut vs. udev), but restarting with monit fixed it. For this just append the following lines to /etc/monit/monitrc after installation and general setup of the monit tool

check process newhidups with pidfile /var/run/nut/newhidups-backups_cs500.pid
	group system
	start program = "/sbin/upsdrvctl start"
	stop program = "/sbin/upsdrvctl stop; sleep 5; /usr/bin/pkill newhidups"
	if 3 restarts within 5 cycles then timeout

Using the pkill command avoids multiple instances of newhidups, since the stop action of upsdrvctl is not very good at this either.