最後更新: 2020-08-05







  • Battery backup x 3
  • surge only x 1 <-- alway on (not controlled by the On/Off switch.)
  • Analog phone line for phone/fax/modem/DSL (Data Line Protection)
  • Communications & Management Interface Port(s):  USB(RJ-45 to USB)


# 600 VA

Audible Alarm
  • Alarm when on battery(Four Beeps Every 30 Seconds)
  • distinctive low battery alarm
  • overload continuous tone alarm




Batteries typically last 3-6 years, shorter if subjected to frequent power outages or elevated temperatures.


Install apcupsd



# Ubuntu 16, 18

apt-get install apcupsd

# Centos 7, 8

yum install apcupsd

Checking cable

ls /dev/usb/hiddev*


lsusb -v -d '051d:' | less

  iProduct                2 Smart-UPS C 1500 FW:UPS 10.0 / ID=1005
  iSerial                 3 ????????????





  • /etc/default/apcupsd
  • /etc/apcupsd/apcupsd.conf

Basic Setting


#### USB Cable Setting ####
UPSCABLE us             # Cable: simple, smart, ether, usb

UPSTYPE usb             # 配合"DEVICE"使用. Type: apcsmart, usb, net ...
DEVICE /dev/usb/hiddev0 # USB: A "blank" DEVICE setting enables autodetection

# Interval (in seconds) at which apcupsd polls the UPS for status.

#### 在使用電池行多耐才解發 shutdown ####
# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction(first win)

# 0 => Disables this timer
# The UPS has run on batteries for TIMEOUT
# longer => apcupsd will initiate a system shutdown

# The remaining battery percentage
# below or equal to BATTERYLEVEL => apcupsd will initiate a system shutdown.

# the remaining runtime in minutes
# below or equal to MINUTES => apcupsd will initiate a system shutdown.

# Time in seconds between annoying users to signoff prior to system shutdown. 0 disables.

#### Log ####
# Location of STATUS file (written to only if STATTIME is non-zero)
STATFILE /var/log/apcupsd.status



Specify the time in seconds between messages requesting logged in users to get off the system during a power failure.
This timer starts only when the UPS is running on batteries.
The default is 300 seconds (5 minutes).

apcupsd sends the annoy messages by invoking the apccontrol script with the annoyme argument.
The default is to send a wall message on Unix systems and a popup message in Windows.

Note that if "NOLOGON disable" is set, the annoy messages will also be disabled.(Default: disable)


Specify delay time in seconds before apcupsd begins requesting logged in users to get off the system during a power failure.
This timer starts only after the UPS is running on batteries. This timer is reset when the power returns.

The default is 60 seconds.
Thus, the first warning to log off the system occurs after 60 seconds on batteries, assuming that NOLOGON is not set to disable.

Start Service

# Ubuntu


ISCONFIGURED=yes                  # Meaning: IS CONFIGURED

/etc/init.d/apcupsd start

Starting UPS power management: apcupsd.

# Centos

systemctl start apcupsd

systemctl enable apcupsd

USP Status

apcaccess status

APC      : 001,027,0663
DATE     : 2018-08-13 15:08:58 +0800
HOSTNAME : kvmhost
VERSION  : 3.14.12 (29 March 2014) debian
UPSNAME  : kvmhost
CABLE    : USB Cable
UPSMODE  : Stand Alone
STARTTIME: 2018-08-13 15:08:49 +0800
MODEL    : Smart-UPS C 1500
BCHARGE  : 100.0 Percent
TIMELEFT : 173.0 Minutes
MBATTCHG : 10 Percent        # 關機設定
MINTIMEL : 5 Minutes         #
MAXTIME  : 0 Seconds         #
ALARMDEL : No alarm
BATTV    : 27.0 Volts
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
STATFLAG : 0x05000008
MANDATE  : 2016-02-07
SERIALNO : ????????????
NOMBATTV : 24.0 Volts
FIRMWARE : UPS 10.0 / ID=1005
END APC  : 2018-08-13 15:08:59 +0800




MAXTIME : Max battery runtime (TIMEOUT) after which system is shutdown

BCHARGE: Current battery capacity charge percentage


NUMXFERS: Number of transfers to battery since apcupsd startup

TONBATT : Seconds currently on battery

CUMONBATT : Cumulative seconds on battery since apcupsd startup

--- Report ---

NUMXFERS: Number of transfers to battery since apcupsd startup

TONBATT: Seconds currently on battery

CUMONBATT: Cumulative seconds on battery since apcupsd startup

XOFFBATT: Date, time of last transfer off battery since apcupsd startup

LASTXFER: Reason for last transfer to battery since apcupsd startup

--- UPS / BATT 是否舊了 ---

MANDATE : UPS date of manufacture

BATTDATE : Date battery last replaced

Other Info

LINEV       : 224.0 Volts            # Current input line voltage

OUTPUTV  : 230.0 Volts            # Current UPS output voltage

NOMPOWER: 400 Watts

LOADPCT  : 21.0 Percent           # Percentage of UPS load capacity used as estimated by UPS

# 觸發跳去電池條件

SENSE: Current UPS sensitivity setting for voltage fluctuations

LOTRANS: Input line voltage below which UPS will switch to battery

HITRANS: Input line voltage above which UPS will switch to battery

# 回復

RETPCT: Battery charge % required after power off to restore power

ALARMDEL: Delay period before UPS starts sounding alarm

SELFTEST: Date and time of last self test since apcupsd startup

STESTI: Self-test interval


其他 Setting



無電多久才觸發 onbattery event (powerout --N sec--> onbattery)


Default = 0

0 = zero delay after pwr fail, T = power fail + 30 sec, L = low battery, N = never


Self test interval in hours.


Events Log



EVENTSFILE /var/log/apcupsd.events


2018-09-16 18:08:52 +0800  Power failure.
2018-09-16 18:08:53 +0800  Power is back. UPS running on mains.
2018-09-24 10:54:37 +0800  Power failure.
2018-09-24 10:54:43 +0800  Running on UPS batteries.
2018-09-24 10:56:10 +0800  Mains returned. No longer on UPS batteries.
2018-09-24 10:56:10 +0800  Power is back. UPS running on mains.
2018-09-25 23:21:31 +0800  Power failure.
2018-09-25 23:21:37 +0800  Running on UPS batteries.
2018-09-25 23:21:39 +0800  Mains returned. No longer on UPS batteries.
2018-09-25 23:21:39 +0800  Power is back. UPS running on mains.




apcupsd -> apccontrol -> onbattery

                     event handler script

apccontrol { <event> <ups-name> <connected> <powered> }

內置 event script: changeme, commfailure, commok, offbattery, onbattery



apcupsd detects that the UPS has switched to battery power and it is not a self-test

Default action -- does nothing.

timeout (TIMEOUT)

send "UPS battery runtime limit exceeded. Doing shutdown." to wall and then exits.

After this event, apcupsd will immediately generate a doshutdown event.

runlimit (MINUTES)

sends "UPS battery discharge limit reached. Doing shutdown" to wall and then exits.


loadlimit (BATTERYLEVEL)

sends "UPS battery discharge limit reached. Doing shutdown" to wall and then exits.



1) sends "Beginning Shutdown Sequence" to wall

2) calls "shutdown -h now"

寫 Script

If you do not want apccontrol to also execute its default action for the selected event,

your program or script must exit with an exit status of 99

echo "wall Server no power" > doshutdown

echo "exit 99" >> doshutdown

chmod 700 doshutdown

Remark: Setting for test script


systemctl restart apcupsd




Test UPS (apctest)


A program that enables the running of certain low-level tests to check UPS

 * apctest displays a menu of options

 * programming of the values of the UPS EEPROM configuration

 * apcupsd stop 後才可以用 apctest


You are using a USB cable type, so I'm entering USB test mode
Hello, this is the apcupsd Cable Test program.
This part of apctest is for testing USB UPSes.

Getting UPS capabilities...SUCCESS

Please select the function you want to perform.

1)  Test kill UPS power
2)  Perform self-test
3)  Read last self-test result
4)  View/Change battery date
5)  View manufacturing date
6)  View/Change alarm behavior
7)  View/Change sensitivity
8)  View/Change low transfer voltage
9)  View/Change high transfer voltage
10) Perform battery calibration
11) Test alarm
12) View/Change self-test interval
 Q) Quit

self-test(2, 3, 12)

During a Self-Test the UPS will run on battery for approximately 10 seconds.

During this time it will test it's internal subsystems as well as the battery.


This test instructs the UPS to perform a self-test
operation and reports the result when the test completes.

Clearing previous self test result...CLEARED
Initiating self test...INITIATED
Waiting for test to complete...COMPLETED
Result of last self test: PASSED


Current Self-test interval: None
 0 for None
 1 for On Power
 2 for 7 Days
 3 for 14 Days
 Q to Quit with no changes


This setting should normally be set to High unless the UPS switches to battery power frequently

less sensitive setting will preserve UPS batteries. (connected equipment can tolerate the power quality)

Current sensitivity setting: MEDIUM
 L for Low sensitivity
 M for Medium sensitivity
 H for High sensitivity
 Q to Quit with no changes

battery date(4)

Current battery date: 05/22/2020
Enter new battery date (MM/DD/YYYY), blank to quit: 08/05/2020

battery calibration(10)

The runtime calibration discharges the UPS battery to approximately 25% of capacity.

 * only be performed if your battery is charged to 100%

 * It is recommended that battery runtime calibration be performed annually

    (As batteries age, they tend to hold less charge)


-o, --power-off               turn off UPS completely

The UPS will not supply power to the system when the utility power returns

-k, --killpower

Power down the UPS in hibernate mode after a 10 second delay.

This option is normally only used by apcupsd itself to power down the UPS after a system shutdown has almost completed.

-p --kill-on-powerfail

apcupsd commands the UPS to power down in hibernate mode just before apcupsd starts the system shutdown.

This relies on the grace shutdown delay of a Smart-UPS being long enough to allow the system to shutdown completely before the UPS shuts off the power to the system and goes into hibernate mode.

This shutdown grace delay is a programmable value stored in a Smart-UPS EEPROM which can be changed using apctest(8).

In hibernate mode, the UPS will again supply power to the system when the utility power returns.

Refer to apcupsd.conf(5) for an alternative method using the KILLDELAY configuration directive and the only method available when using a Back-UPS or other UPS operating in simple signalling mode.

-t --term-on-powerfail

apcupsd exits immediately when it issues the system shutdown command.

This behaviour is useful for those systems where it is not possible to insert apcupsd commands in a halt script to issue the killpower command.

Without this option, apcupsd will wait for the SIGTERM signal from the system shutdown process before exiting.