Notes on APC UPS and graceful shutdown...

...especially under Linux.

Russell Bateman
July 2018
last update:

UPS used to come with a tiny RJ-11 connector to attach to your Windows host in order to tell special software when to shut down gracefully. This didn't work for Linux. Since the advent of USB to replace the RJ-11 and the creation of special drivers, this is now possible.

Requirements

Of course, when you get to the real Linux steps, if you're running Windows, there's just the software that comes with the APC UPS to install. I don't think I really need to cover that.

What you need is a UPS that is specifically designed to perform shut-down. Schneider Electric's APC SmartUPS line satisfies this.

  1. APC SmartUPS, has USB data port, typically USB 2.0 Type B: e.g.: APC 600VA UPS Battery Backup & Surge Protector
  2. USB cable, type B to type A

Procedure

  1. Set up UPS according to instructions.
  2. Connect UPS to computer to protect via USB cable above: https://www.youtube.com/watch?v=BL6EOK8TxPs
  3. Follow instructions to configure and control APC SmartUPS in power failure: https://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-install-apcups/

Other links that may be useful



CyberPower 650VA Battery Backup

I bought this for under $50 on sale from TigerDirect. Here's my experience installing the software before hooking the unit to my server. A few months later, I repeated this experience and it went identically to this.First, get the Debian 64-bit download:

https://www.cyberpowersystems.com/product/software/powerpanel-for-linux/

Then, install and configure it:

root@tol-eressea:~/Downloads# dpkg --install powerpanel_132_amd64.deb
Selecting previously unselected package powerpanel.
(Reading database ... 106685 files and directories currently installed.)
Preparing to unpack powerpanel_132_amd64.deb ...
Unpacking powerpanel (1.3.2) ...
Setting up powerpanel (1.3.2) ...
[ ok ] Starting pwrstatd (via systemctl): pwrstatd.service.
Installation accomplish!

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@tol-eressea:~/Downloads# systemctl status pwrstatd.service
 pwrstatd.service - LSB: The monitor UPS software.
   Loaded: loaded (/etc/init.d/pwrstatd; generated)
   Active: active (running) since Thu 2018-11-29 22:54:17 UTC; 19s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 12622 ExecStart=/etc/init.d/pwrstatd start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/pwrstatd.service
           └─12638 /usr/sbin/pwrstatd

Nov 29 22:54:17 tol-eressea systemd[1]: Starting LSB: The monitor UPS software....
Nov 29 22:54:17 tol-eressea pwrstatd[12622]:  * Starting pwrstatd 1.3.2
Nov 29 22:54:17 tol-eressea pwrstatd[12622]:    ...done.
Nov 29 22:54:17 tol-eressea systemd[1]: Started LSB: The monitor UPS software..
root@tol-eressea:~/Downloads# which pwrstat
/usr/sbin/pwrstat
root@tol-eressea:~/Downloads# pwrstat -status

The UPS information shows as following:

  Current UPS status:
      State........................ Lost Communication

Later, after connecting my UPS to power, shutting down my server and plugging it into the UPS:

root@tol-eressea:~# pwrstat -status

The UPS information shows as following:

  Properties:
    Model Name................... SX650G
    Firmware Number.............. BF01101F681.y
    Rating Voltage............... 120 V
    Rating Power................. 375 Watt

  Current UPS status:
    State........................ Normal
    Power Supply by.............. Utility Power
    Utility Voltage.............. 120 V
    Output Voltage............... 120 V
    Battery Capacity............. 100 %
    Remaining Runtime............ 26 min.
    Load......................... 75 Watt(20 %)
    Test Result.................. Unknown
    Last Power Event............. None

So, the software is talking to the UPS. Whether or not it will safely power down my server remains to be tested (or seen). What was different the second time was the power draw (Load) which is 150+ Watts. I need to examine just what's connected to the battery side to see if I can't reduce it. I think there's a printer plugged into the same power strip plugged into the UPS, so I may have to do some arranging.

Another thing that's different the second time is that it's not backing up power to server hardware, but to my main development host (with a desktop, of course). I saw what's below. You get the Power Management dialog when you click on Power Settings. Very nice integration, I think.