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:

[email protected]:~/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) ...
[email protected]:~/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..
[email protected]:~/Downloads# which pwrstat
/usr/sbin/pwrstat
[email protected]:~/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:

[email protected]:~# 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).