UPS on FreeBSD

Last night my long serving brick of a UPS died ... and to put it bluntly I feel almost naked without a UPS protecting my home server. This left the question of what to acquire. Top of my list of priorities was to have a serial interface - USB is just too painful to contemplate after the last time I configured a UPS on FreeBSD (Another CyberPower I blogged about in January 2013) and it would be nice if it worked with Network UPS Tools (NUT).

I ended up acquiring a CyberPower Value1200eLCD - and managed to get it working on FreeBSD ... but not with NUT apparently the people at CyberPower have backed away from the openness that they once embraced and also changed their protocols.


With a certain amount of fiddling I managed to get the Linux version of the CyberPower PowerPanel for Linux to work under FreeBSD. I should note that this is not the most spectacularly written piece of software
1 and one Linux specific shortcut2 made using the software much harder. But I did get it work and it looks like it will be more reliable than the USB based unit I blogged about earlier.

Fortunately, the daemon and its companion program run under the linuxulator. The linuxulator recognises Linux ELF files and emulates / maps the system calls so that some Linux ELF binaries run on FreeBSD. It also has a neat trick with remapping files so that it first checks for files in the /compat/linux directory hierarchy before checking for files in the normal system root. This trick is required twice to get the software to work:

  1. Remapping the Linux /dev/ttyS1 to a FreeBSD serial port (/dev/cuau0 in my case); and,
  2. Providing a replacement for /sbin/shutdown that understands the command hard coded into the daemon.

I wrapped the solution up into a
tarball containing some trivial code, and a Makefile to distill the knowledge and you can collect the binaries from their website (http://www.cyberpowersystems.com/products/management-software/ppl.html?selectedTabId=resources&imageI=#tab-box) specifically PowerPanel for 32 bit Linux .tar 1.2.3 (Linux 32 bit) in my case. I must admit it would have been nicer if they had either built FreeBSD binaries or best of all released their source code3.

Now I can sleep better knowing my main system can skate over short power outages and shutdown cleanly.




1. The daemon runs as root - it is not clear that this is actually necessary and hence a potentially avoidable security risk.

2. Apparently Linux is happy with the command /sbin/shutdown -h 0. FreeBSD and many other Unix derivatives require a “+” sign in front of the zero to distinguish absolute times from relative times. The shutdown command is hard coded into the daemon.

3. It would be interesting to know if their shift to a more closed position was driven by philosophy - e.g. we are not giving away the code that might benefit our competitors - or a legal restriction based on buying components from others that prevents them distributing the protocol in a non-compiled form.