Don’t Interrupt Me

UPS: no, not the company that delivers parcels all over the world. I’m talking about Uninterruptible Power Supplies.

It was about time the house had one, so I took the plunge and purchased one. In fact, I did this about two weeks ago. It arrived a few days later and was still lying in its box in the hallway until yesterday.

It wasn’t just laziness that kept it in its packaging. It’s an APC Smart-UPS RT5000 XL, which is quite a heavy-duty unit. As such, it needed its own heavy-duty electrical group in the house, which meant that a qualified electrician had to come to perform the work.

One of the parts that the electrician needed for the job took a week to arrive, so it wasn’t until yesterday that the work to install the UPS was completed. At last, the UPS, a hulking great thing weighing in at around 60 kg, could be lugged downstairs to the cellar and installed in the cupboard under the stairs. More bright LEDs to peer back at me from the darkness!

I seized the opportunity to have the electrician rewire one of the other electrical groups, so that one of the sockets in my office is now routed via the UPS. This means that my desktop computer, monitor, telephone and fax can all connect to it, which saves me from having to buy a separate unit for the office. That’s very cool.

Downstairs, my Linux server, the ReadyNAS NV+ storage server, a USB-attached hard drive, an Ethernet switch and the DSL modem are all connected to the UPS. Assuming I haven’t forgotten a vital piece of infrastructure, we should now be able to continue to use the Internet and make phone calls in the event of a power-cut.

All of the above equipment is good for a load of about 12% (the load fluctuates depending on whether I’m compiling code, whether the monitor’s turned on, etc.), which means that the UPS’s battery will provide back-up power for about 95 minutes. I can get an extra 15 minutes out of it if I turn off inessential equipment in the office.

I actually made a blunder when researching this product. It has a network management card, which is basically an Ethernet card with some bells and whistles, such as a port for attaching a temperature probe. I thought it additionally had a USB port for direct monitoring via a cable, but I somehow imagined that detail. Smaller units do have this feature, because they’re typically missing the Ethernet interface.

The only reason I wanted the ability to monitor the UPS over a USB cable was because that’s what the ReadyNAS box requires in order to be able to automatically shut down when the UPS’s battery is running low. Large disc arrays really don’t like it when the power just disappears and I wanted my box to be able to gracefully shut down.

Where there’s a will, there’s a way, though; well, sometimes, anyway. I set out to find a fix for the problem today.

It turns out that the ReadyNAS uses Network UPS Tools (or NUT for short) to perform its UPS monitoring. Reading NUT’s documentation, it became apparent that it has a number of back-end drivers for monitoring UPSes. One of these is snmp-ups, which, as the name suggests, uses the SNMP protocol to monitor UPSes.

My APC UPS can be queried and configured using SNMP, so this seemed like a good avenue to explore.

snmp-ups supports a number of MIBs. If you don’t know what a MIB is, think of it as a formalised set of questions that can be asked of a device. One of snmp-ups’s MIBs is called apcc, which is designed for use with APC units. Bingo.

Well, snmp-ups is an experimental driver and its man page warns that it’s not suitable for production use, so I wasn’t sure whether it would work. However, once I had installed NUT on my Linux server, configured it and started the server daemon, upsd, I was able to query for the status of the UPS from any host on the network.

The ReadyNAS has a feature that allows it to monitor a UPS attached to a second or subsequent ReadyNAS unit elsewhere on the network. Since those units are also running NUT, all the ReadyNAS is doing when it performs this remote monitoring is contacting the NUT server on the other unit. By installing a NUT server on my Linux box, I was hoping to pass it off as a second, UPS-backed ReadyNAS unit in the eyes of my ReadyNAS.

I went into the ReadyNAS’s FrontView interface, went to System -> Power -> UPS Configuration and gave it the IP address of my Linux server as the system to be monitored. Sadly, an error message popped up, informing me that a connection couldn’t be established.

I delved into my sysadmin toolkit and pulled out a perennial troubleshooting tool, tcpdump(8). This utility is used to analyse network traffic.

Within a few seconds, I was able to see where the communication was going awry: the ReadyNAS expected the system it was querying to have information available about a device called UPS. I had called my UPS apc in the NUT config.

Once I had renamed the monitored device and restarted upsd, the ReadyNAS was happy to believe that the NUT instance on my Linux server was, in fact, a second ReadyNAS box with which it could communicate.

Here’s the pudding containing the proof:

FrontView screenshot of ReadyNAS monitoring remote UPS via NUT server

I’m very happy I was able to get this to work, because having auto-shutdown on the ReadyNAS was the one thing that had prompted me to invest in a UPS in the first place. It would have been a bummer if precisely that feature hadn’t been available to me.

I also want my Linux server and desktop to automatically shut themselves down in the event of a power-cut. I could use NUT, but because the snmp-ups driver is marked experimental, I consider it safer to use the very mature apcupsd software. After all, apcupsd is designed specifically for use with APC UPSes.

apcupsd is actually a package I had on my list of things to investigate eight years ago when I was working at Linuxcare, but it’s taken me until now to actually delve into it. It’s very easy to configure and does exactly what it’s supposed to do.

There’s also a nice little GTK2 GUI client that will talk to an instance of apcupsd. It’s called gapcmon and is trivial to get up and running. You can put an icon for it in your tray and call it up whenever you want check the status of your UPS.

In conclusion, a UPS isn’t a very interesting device to add to your network. It’s expensive, heavy and you hopefully won’t get much use out of it. As is often the case with insurance, however, it can be very painful to discover after a catastrophe that one should have had it. For that reason, I feel good about my purchase.

Besides, this UPS has a few interesting aspects to it. For a start, it’s networked, which is always a desirable quality. It also works with Linux without the need for any proprietary software, which is another very desirable quality.

I hope that Netgear will add the snmp-ups driver to a future release of the ReadyNAS firmware. That will obviate the need for an extra computer to function as a NUT server.

This entry was posted in Technology. Bookmark the permalink.

5 Responses to Don’t Interrupt Me

  1. Yeechang Lee says:

    Hey, thank you for the tip on using ups as the UPS’s name. I now have my ReadyNAS connected to the UPS that powers it (but is connected to another device).

  2. Dan says:

    How did the experiment with apcupsd go? I’m not able to get my ReadyNAS to recognize an APC ups connected to another box running it, though I tried the name change trick.

    • ianmacd says:

      apcupsd is working for me to directly monitor the UPS from Linux PCs and shut them down if things get critical. The ReadyNAS, however, uses NUT to monitor a UPS.

      I have 3 ReadyNAS units now. As of RAIDiator 4.2.16, the Pro Business and Pro 6 are both capable of monitoring a networked APC UPS over SNMP, so the problem is fixed for those machines.

      The NV+, on the other hand, is still running 4.1.x and therefore has to have an intermediary NUT server to consult. This NUT server monitors the networked APC over SNMP and can be set up as follows:

      /etc/ups/nut.conf needs to contain:

      MODE = netserver
      

      /etc/ups/ups.conf needs to contain:

      [UPS]
      driver = snmp-ups
      port = 192.168.1.12 {address of your APC)
      community = public
      snmp_version = v1
      mibs = apcc
      

      And /etc/ups/upsd.conf needs to contain:

      LISTEN 127.0.0.1
      LISTEN 192.168.1.51 (address of NUT server)
      

      Now, tell your NV+ to monitor 192.168.1.51 and you should get the green light.

  3. jonah says:

    Hi I wonder if you can please help. I have a similar situation and want to edit the readynas to connect to my other server running NUT with an APC UPS…

    I’ve tried just as you did and added the ups name, user and password the readynas expects to my server nut config files but when I enter the server IP in Frontview on the Readynas I always get this error “Could not connect to the specified UPS server. Please verify that UPS sharing is enabled on that system and try again.”

    Thanks for any help at all. It’s driving me bonkers. Do I somehow have to share the ups on the server? Any help really appreciated. thanks.

    • jonah says:

      hi I found the problem. I was running in STANDALONE mode and not NETSERVER, so now I have the green light at last! Thank you for a great guide.

      Just one last thing, is it safe to run in netserver mode, is there a way to make remote connections only work through my local network with those LISTEN COMMANDS etc or will that happen by default? Currently I’ve only added:

      LISTEN 127.0.0.1 LISTEN 192.168.0.24

      in my upsd.conf file, with .24 being my server address…

Leave a Reply

Your email address will not be published. Required fields are marked *