Adventures in UPS Management

Always one for “if it’s worth doing, it’s worth overdoing”, I use a rather oldschool 2RU rackmount 3kVA Compaq UPS (R3000h, OEM badged PowerWare 5119) for my network core, NAS, ESXi and workstation.

It was a cheap buy at ~$100 sans batteries, I just threw 4 7.2AH SLA batteries into it and called it good (I also have a much larger UPS, but it’s in need of a new battery pack, and being that it’s internal pack is *20* 7.2AH SLAs, it’s rather $$$ to replace).

For the first time in two and a half years since we bought this place we had a blackout yesterday morning…

The “pleasure” of having to go and manually shutdown all my machines at 05:30 was enough to FINALLY spur me into getting off my arse and actually setting up monitoring for the UPS.

The first challenge was building a cable that ACTUALLY BLOODY WORKED with this UPS (pro-tip; DO NOT plug a straight-through serial cable into a Compaq R3000h, the UPS will IMMEDIATELY and without warning power down…)

After various false starts, I FINALLY got a working cable up and running (found several different pinouts floating around online), the UPS speaks UPSCode2 and the cable to talk to it is as follows;

r3000h-cable

Oddball comms parameters too 1200 8-n-1 software flow control (Xon/Xoff), if you’re interested check out the UPSCode2 Concept Description which includes all of the protocol info.

Spent some time arguing with Powerware LanSafe trying to get it to play ball, eventually gave up and spent some time digging around for other solutions. Initially I looked at apcupsd because I knew it existed, but that doesn’t support upscode2, some further digging turned up Network UPS Tools which fit the bill, as a bonus there are clients available for *nix, Windows and ESXi.

Now to choose a UPS server, decided the best option was my NAS which is a FreeBSD box, and as an added bonus it has a real, legit, serial port onboard, hooked the UPS up there, installed NUT from ports.

nut.conf;

MODE=netserver

ups.conf;

[compaq3kva]
 manufacturer=Compaq
 driver=upscode2
 port=/dev/ttyu0

Added a couple of LISTEN clauses to upsd.conf;

LISTEN 127.0.0.1 3493
LISTEN 192.168.0.120 3493

Added a couple of users to upsd.users.
Et viola;

# upsc compaq3kva@lodestone
battery.capacity.nominal: 17.00
battery.charge: 95.0
battery.runtime: 2280
battery.voltage: 55.20
battery.voltage.maximum: 56.00
battery.voltage.minimum: 40.00
battery.voltage.nominal: 48.00
device.mfr: Compaq
device.model: UPS 3000 VA FW -0033
...
ups.mfr: Compaq
ups.model: UPS 3000 VA FW -0033
ups.power.nominal: 3000.00
ups.status: OL

So we’re all good there.

A few tweaks to upsmon.conf (mainly switching out -h for -p in SHUTDOWNCMD), and a quick test, and we’re golden.
Also enabled CGI on the webserver on that box to allow me to monitor the UPS;

UPS Stats from NUT

UPS Stats from NUT

I’ll probably enable SSL at some point but for the moment it works.

For my firewall box (pfSense) it was very straightforward to integrate, basically just installed the nut package and pointed it back at the NAS box.

Getting the ESXi integration to work was a bit of a pain in the arse, so I’ll write that up separately.

Next cab off the rank will be integrating my Windows box, which will be a little more involved because I also want to suspend any VMWare VMs which happen to be running on it at the time, prior to shutdown (either some PowerShell + VMWare vmrun voodoo, or I might write a quick’n’dirty app to do that), so that’ll get a separate write up too.

Oh, and one more thing, had to add the following to /etc/devfs.conf to ensure that NUT had access to the serial port;

own    ttyu0    root:uucp
perm   ttyu0    0660

All in all it was a relatively painless process, the biggest issue being getting the right damn cable made…

Morgan / 2016-11-08 / Uncategorized / 0 Comments