apcupsd: Configuring APC UPS Monitoring and Shutdown

apcupsd is a single daemon that monitors an APC UPS and shuts the computer down cleanly. For a USB APC unit you edit one file, /etc/apcupsd/apcupsd.conf, and check the result with apcaccess status.

On this page
  1. Where apcupsd fits
  2. A working USB configuration
  3. Start it and read the status
  4. Sharing one UPS with other machines
  5. Event scripts with apccontrol
  6. apctest: diagnostics and settings
  7. Killpower and automatic restart
  8. Working with non-APC hardware
  9. apcupsd vs NUT
  10. Frequently asked questions

Where apcupsd fits

apcupsd has been around since the late 1990s and is still packaged by most Linux distributions and BSDs. It is also the engine behind Unraid's built-in UPS settings (see Unraid UPS setup). Its appeal is simplicity: one daemon, one config file, one status command, and sensible defaults for APC hardware.

Its limits are equally clear. Development has been quiet for years, it is designed around APC's protocols, and its network model is less flexible than Network UPS Tools. If you have an APC unit and one or two Linux machines, it is a fine choice. For anything bigger or mixed, read the comparison at the end first.

A working USB configuration

Install the package (named apcupsd on major distributions), then edit /etc/apcupsd/apcupsd.conf. These are the lines that matter for a typical USB-connected APC unit; leave the rest at defaults.

## /etc/apcupsd/apcupsd.conf
UPSNAME office-ups
UPSCABLE usb
UPSTYPE usb
DEVICE
POLLTIME 60

## Shutdown thresholds: whichever is reached first wins
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0

## Events
ONBATTERYDELAY 6
ANNOY 300
ANNOYDELAY 60

## Network information server (for apcaccess and remote clients)
NETSERVER on
NISIP 127.0.0.1
NISPORT 3551

What each setting does

Key apcupsd.conf directives
DirectiveExampleMeaning
UPSCABLEusbCable type. usb for USB; smart or a cable part designation for serial; ether for network clients
UPSTYPEusbProtocol driver: usb, apcsmart (serial Smart-UPS), net (another apcupsd), snmp, and others depending on build
DEVICE(blank)Blank for USB autodetect; a serial port such as /dev/ttyS0; or host:3551 for network clients
BATTERYLEVEL5Shut down when charge falls to this percent
MINUTES3Shut down when the UPS's runtime estimate falls to this many minutes
TIMEOUT0Shut down after this many seconds on battery; 0 disables the timer
ONBATTERYDELAY6Seconds after a power failure before the onbattery event fires (filters blips)
NETSERVERonEnables the network information server used by apcaccess and clients
NISIP127.0.0.1Address to listen on; set to the LAN address (or 0.0.0.0) to serve clients
NISPORT3551TCP port for the information server

Defaults for NISIP differ between the upstream sample file and some distribution packages. Set it explicitly so you know what it is.

Our rule of thumb: the defaults are too late for most servers

BATTERYLEVEL 5 and MINUTES 3 are the shipped defaults, and on a fresh battery with a light load they work. But a 3 minute estimate from an aging battery under a heavy load can collapse to well under a minute, and a NAS or VM host may need several minutes to stop cleanly. For servers, a more forgiving starting point is MINUTES at about twice your measured shutdown time, plus a TIMEOUT of a few minutes if your outages are usually either short blips or long. See how much runtime you need.

Start it and read the status

sudo systemctl enable --now apcupsd
apcaccess status

On older Debian and Ubuntu packages you also had to set ISCONFIGURED=yes in /etc/default/apcupsd before the service would start. If apcaccess returns quickly with a page of fields, the daemon is talking to the UPS. The fields you will look at most:

Useful apcaccess status fields
FieldMeaningWhat to watch for
STATUSONLINE, ONBATT, LOWBATT, CAL, TRIM, BOOST, COMMLOST, SHUTTING DOWN, and combinationsCOMMLOST means apcupsd cannot reach the UPS
LINEVInput line voltageFrequent dips near the transfer point explain repeated switching to battery
LOADPCTLoad as a percent of capacitySustained high load shortens runtime sharply; see UPS load percentage
BCHARGEBattery charge percentShould return to 100 within hours of an outage
TIMELEFTEstimated runtime in minutes at current loadCompare with MINUTES; drifts with battery age until recalibrated
BATTVBattery voltageCompare with NOMBATTV; low when charged suggests a weak battery
LOTRANS / HITRANSTransfer voltagesWhere the UPS switches to battery
LASTXFER, NUMXFERS, TONBATT, CUMONBATTLast transfer reason, count and time on batteryA good diagnostic for a UPS that keeps switching to battery
SELFTEST, BATTDATELast self-test result, battery dateBT or failed results mean the battery needs attention

Not every model reports every field, and USB Back-UPS units usually report fewer than Smart-UPS units.

Sharing one UPS with other machines

The host with the USB cable runs apcupsd as above with the information server reachable on the LAN:

## On the server (USB-connected host)
NETSERVER on
NISIP 192.168.1.10
NISPORT 3551

Each other machine runs apcupsd in client mode, polling the server instead of a cable:

## On each client
UPSCABLE ether
UPSTYPE net
DEVICE 192.168.1.10:3551
POLLTIME 10
BATTERYLEVEL 20
MINUTES 8
TIMEOUT 0

The client applies its own thresholds to the data it reads. Set them higher than the server's so clients finish shutting down while the server is still up. The older apcupsd docs called these clients "slaves"; the mechanism is the same.

Port 3551 has no authentication

The information server is read-only, but anyone who can reach it can see your UPS status, and a client trusts whatever it receives. Bind NISIP to a LAN address, allow 3551 only from your LAN in the host firewall, and never forward it from the internet.

Event scripts with apccontrol

When something happens, apcupsd calls /etc/apcupsd/apccontrol with the event name. The default script logs a message, notifies logged-in users and, for shutdown events, calls the system shutdown. To customize an event, create an executable script in /etc/apcupsd/ with the event's name. apccontrol runs it first; if your script exits with code 99, apccontrol skips its own default action for that event.

Frequently customized apccontrol events
EventWhen it firesTypical custom action
onbatteryPower failed and ONBATTERYDELAY passedSend an email or push alert
offbattery / mainsbackUtility power returnedSend an all-clear
doshutdownA threshold was reachedStop VMs or containers, then shut down
commfailure / commokLost or regained contact with the UPSAlert: a dead link means no protection
changemeUPS reports the battery needs replacingAlert; see when to replace a UPS battery

A minimal /etc/apcupsd/onbattery script:

#!/bin/sh
# $1 is the UPS name passed by apccontrol
echo "UPS $1 on battery at $(date)" | mail -s "Power failure" admin@example.com
exit 0

Exiting 0 lets the default actions still run. Many distributions already ship small onbattery and offbattery scripts that send mail to root, so check before overwriting.

apctest: diagnostics and settings

apctest is an interactive tool that talks to the UPS directly. Stop apcupsd before running it, because both cannot hold the device. Depending on the UPS model and connection type, it can run a battery calibration, test killpower, and on some models read or change EEPROM settings such as transfer voltages and alarm behavior. Menus vary with the connection: USB units typically expose fewer options than serial Smart-UPS units. Start apcupsd again when finished.

Killpower and automatic restart

After a threshold-triggered shutdown, the system's halt scripts call apcupsd's killpower routine, which tells the UPS to turn its outputs off after a delay. When utility power returns, the UPS restarts output and machines set to power on after AC loss boot. Whether this works depends on the distribution's shutdown integration and the UPS model, so verify it once with a real test at a planned time.

Working with non-APC hardware

apcupsd's USB driver uses HID Power Device reports, which many brands share. Some non-APC units therefore show basic data. Results are inconsistent, though: values may be missing or misread, and shutdown commands may not work. Treat non-APC support as partial at best, and prefer NUT for those units.

apcupsd vs NUT

Choosing between apcupsd and Network UPS Tools
apcupsdNUT
Hardware supportAPC focused; partial for other HID unitsMany brands over USB, serial, SNMP and more
ConfigurationOne fileSeveral small files, clear role separation
Network port35513493
Network authenticationNonePer-user passwords and roles
Coordinated multi-host shutdownEach client uses its own thresholdsPrimary declares FSD and waits for secondaries
Development activityLow; mature and stableActive, regular releases
Built into platformsUnraidSynology, TrueNAS, Home Assistant integration, many others
Best forOne or two Linux hosts on an APC UPSAnything mixed, networked or long-lived

Bottom line

If apcupsd is already working on an APC unit, there is no urgent reason to replace it. For new setups, especially homelabs with a NAS, a hypervisor and Home Assistant on one UPS, NUT is the better long-term foundation. If the computer cannot see the UPS at all, start with UPS not detected by computer.

Frequently asked questions

Does apcupsd work with CyberPower or Eaton UPS units?

Sometimes, partially. Because apcupsd's USB driver speaks the generic HID Power Device protocol, some non-APC units report basic status like on-battery and charge. Others report wrong values or are not recognized, and killpower may not work. For non-APC hardware, Network UPS Tools is the more reliable choice.

Why does apcaccess say Connection refused?

apcaccess reads from apcupsd's network information server, so it fails if apcupsd is not running or NETSERVER is off. Check systemctl status apcupsd, confirm NETSERVER on, and confirm apcaccess is pointed at the address in NISIP. On Debian-based systems, older packages also required enabling the daemon in /etc/default/apcupsd.

What does TIMELEFT mean in apcaccess output?

It is the UPS's own estimate of runtime in minutes at the current load. It depends on the battery calibration in the UPS firmware, so on an aging battery it can be optimistic. A runtime calibration, done from the UPS or vendor software, updates the estimate. Treat it as a guide, not a guarantee.

Can apcupsd and NUT run on the same machine?

Not against the same USB UPS. Both want exclusive access to the device and will interfere with each other. You can, however, run apcupsd on one host and let NUT on another host read from it, since NUT has an apcupsd client driver, though most people simply pick one tool for the whole network.

How do I stop apcupsd from shutting down on short power blips?

Short blips do not trigger shutdown; only the three limits do. If notifications on every blip are annoying, raise ONBATTERYDELAY so the on-battery event waits a few seconds before firing. Frequent blips themselves usually point to power quality issues or a sensitivity setting worth reviewing on the UPS.

Sources and further reading

  1. apcupsd project site and user manual
  2. apcupsd man pages: apcupsd(8), apcupsd.conf(5), apcaccess(8), apctest(8), apccontrol(8)
  3. Network UPS Tools documentation (apcupsd-ups driver)
  4. APC by Schneider Electric, Back-UPS and Smart-UPS user manuals