Using a UPS with Linux
• Mark Eschbach
For my primary home computer I finally got a UPS. It was about time :-). PG&E doesn’t have many outages around here, however there are many short blips of power loss. Really my use cases are two fold: gloss over the short power outage periods and gracefully shutdown in the case I can’t. I’ve go the UPS installed and the USB cable plugged in.
[821938.616411] usb 6-2: new full-speed USB device number 2 using uhci_hcd [821938.793487] usb 6-2: New USB device found, idVendor=0764, idProduct=0501 [821938.793490] usb 6-2: New USB device strings: Mfr=3, Product=1, SerialNumber=2 [821938.793492] usb 6-2: Product: CP1500PFCLCD [821938.793494] usb 6-2: Manufacturer: CPS [821938.793496] usb 6-2: SerialNumber: 000000000000 [821938.832916] hid-generic 0003:0764:0501.0003: hiddev0,hidraw2: USB HID v1.10 Device [CPS CP1500PFCLCD] on usb-0000:00:1d.0-2/input0
Look promising. The vendor’s name is a bit disconcerting though. Let’s see what I need to do to get some real infromation from it. Arch Linux to the rescue!.
Bummer as it looks like the network tool isn’t available for my specific model. All well. Oh, wait! Looks like it might given the output of
lsusb! I’ll come back to the network utilites. First I just want to see if I can query the device.
Time to see if Ubuntu has the powerpanel package! Nope.
I wonder if I’m missing UPS drivers from my kernel. Random thought and probably not right, but I’ve been wrong before. An
lsmod |grep power returned an
intel_powerclamp driver. I wonder what that is. Interesting: it’s used a method to reduce power consumption to meet either power or cooling requirements. I feel like everytime I look through the drivers I find something new.
Anyway, on to the task at hand. Searching the Ubuntu caches on my machine for
ups there weren’t very many results. Turns out one should really search for
nut as that is where the actual package for the network software is. Turns out you need to install more than
nut-client. Trying the metapackage
nut! Hmm, didn’t get the
nut-scanner installed. I’ve got
Alrighty, I’m stalled. Time for another aproach. Ted Felix seems to have a published a Ubuntu specific article on the subject. May have spoken too soon: he direct you to BlastSpike for how to configure the system with original details. His article is a bit more hand holdy, so let’s see where that gets us. I pretty much used Ted Felix’s example to get it started. I skipped the whole reboot cycle. Hopefully that doesn’t bite me.
[icarus] driver = usbhid-ups port = auto desc = "ecenter UPS"
From here I spun up the
sudo upsdrvctl start to get the output:
Network UPS Tools - UPS driver controller 2.7.4 Network UPS Tools - Generic HID driver 0.41 (2.7.4) USB communication driver 0.33 Using subdriver: CyberPower HID 0.4
Rushing head first into the system: I tried
upsc icarus@localhost. That failed. Turns out the service isn’t bound on the default port. Issuing
systemctl status upsd yielded:
Oct 17 21:59:10 kal systemd: Starting LSB: Network UPS Tools initscript... Oct 17 21:59:10 kal nut-server: * nut-server disabled, please adjust the configuration to your needs Oct 17 21:59:10 kal nut-server: * Then set MODE to a suitable value in /etc/nut/nut.conf to enable it Oct 17 21:59:10 kal systemd: Started LSB: Network UPS Tools initscript.
Doh! Helps if I read the configuration file a little better. Set the
/etc/nut/nut.conf file value to
MODE=standalone and boom! A
sudo systemctl restart upsd and it’s off. Hmm, it’s got some interesting data. But I was hoping I would have more useless nerd datum to nerd on. All well. Anyway, time to figure out the last part: having the system shutdown properly.
Ted Felix recommended another article for the shutdown. srackham’s write up looks complete. Following the instruction for configuring the monitor was fairly painless. I opted to hook into the
LOWBATT signal instead though, as the goal of the system is to survive short outages. Hopefully this works.