QNAP TS-109 Pro UPS Support

, , ,

I recently purchased a QNAP TS-109 Pro. This is basically a hard drive enclosure with a Linux box inside. It is a NAS (Network Attached Storage) and typically does not connect directly to your computer. It's intended to be used as a standalone server, from which you can share files, host your web site, etc. That barely scratches the surface of what it can do.

Anyway, since it is a "full blown" computer, it doesn't like power failures too much. In fact, from reading the forums, a power failure at the wrong moment could create all sorts of problems. So, UPS support with an orderly shutdown in case of power failure was a must.

The problem is that the QNAP only supports UPSs from APC. None of my UPSs were compatible. What I did notice was that the QNAP did support remote UPS monitoring via SNMP. I'd not long finished a home brew NTP server and had a prototype board floating around doing nothing.



idea Solution - get this board to monitor the UPS state (the easy part) and report that to the QNAP via SNMP compatible with the APC protocol (the hard part).

I was very pleased at how well the prototype design matched the UPS monitoring requirements - two bi-colour LEDs to reflect the state of the battery (good/low) and mains power (good/fail), and the serial port with enough I/O pins to connect to the UPS monitoring port (which isn't a serial port, it just connects internally to a couple of relays inside the UPS).

The hard part was figuring out the SNMP protocol. It's sad, but there's no way anyone could implement it just from reading the specification documents. Far too much vital information just isn't there! Nevertheless, by looking at some Wireshark sample captures, using what little information made sense in the relevant RFCs, and then finally lots of trial-and-error building packets and seeing how Wireshark interpreted them, I was able to put together a working SNMP Trap packet the QNAP server understood. (Edit: After searching some more, I've found a lot of the binary structure can be explained by Basic Encoding Rules.)

The way the QNAP handles a remote UPS is very simple. It has an SNMP daemon that waits for a certain set of SNMP traps to be sent to it. Those traps indicate the UPS state. The config file /etc/config/ups_snmptrapd.conf on the QNAP has all the important details.

After all that, I now have a network-enabled UPS! Yay! party

Next project - can my Windows XP computer do something with those SNMP traps? (Edit: The answer is: Yes!)

Feeling Geeky!Windows SNMP UPS Support

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.

February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29