Introduction

The package apcupsd provides a daemon which will monitor your APC UPS, and shutdown the system when power is no longer being supplied to the UPS.

Prerequisites

An APC UPS. The apcupsd daemon works with most APC Smart-UPS models, as well as most simple signaling models, such as Back-UPS, and BackUPS-Office.

Installation

When using systemd

This example assumes you are using a APC Smart-UPS 750 via USB.

First, install the apcupsd package via a terminal:

sudo apt-get -y install apcupsd

Next, backup the original configuration files:

sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.bak

Next, edit the configuration files:

sudo nano /etc/apcupsd/apcupsd.conf

UPSNAME smartups750
UPSCABLE usb
UPSTYPE usb
DEVICE 
POLLTIME 60

sudo cp /etc/default/apcupsd /etc/default/apcupsd.bak

sudo nano /etc/default/apcupsd

ISCONFIGURED=yes

Now one may check the status of the UPS via a terminal:

apcaccess status
APC      : 001,027,0660
DATE     : 2015-09-26 18:39:09 -0500  
HOSTNAME : pc
VERSION  : 3.14.12 (29 March 2014) debian
UPSNAME  : smartups750
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2015-09-26 18:39:08 -0500  
MODEL    : Smart-UPS 750 
STATUS   : ONLINE 
BCHARGE  : 100.0 Percent
TIMELEFT : 51.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
ALARMDEL : 30 Seconds
BATTV    : 27.1 Volts
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000008
MANDATE  : 2010-07-08
SERIALNO : XXXXXXXXXXXX
NOMBATTV : 24.0 Volts
FIRMWARE : COM 02.1 / UPS.05.D
END APC  : 2015-09-26 18:39:19 -0500  

In order to run apctest, one must first stop apcupsd via a terminal:

sudo systemctl stop apcupsd

Otherwise, one may see the following error:

sudo apctest
2015-09-26 18:57:38 apctest 3.14.12 (29 March 2014) debian
Checking configuration ...
sharenet.type = Network & ShareUPS Disabled
cable.type = USB Cable
mode.type = USB UPS Driver
apctest FATAL ERROR in apctest.c at line 335
Unable to create UPS lock file.
  If apcupsd or apctest is already running,
  please stop it and run this program again.
apctest error termination completed

Then execute:

sudo apctest


2015-09-26 18:59:38 apctest 3.14.12 (29 March 2014) debian
Checking configuration ...
sharenet.type = Network & ShareUPS Disabled
cable.type = USB Cable
mode.type = USB UPS Driver
Setting up the port ...
Doing prep_device() ...

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

Select function number:

Once done, start apcupsd:

sudo systemctl start apcupsd

apcupsd-cgi via Apache

The following changes to a Ubuntu system should allow APCUPSD-CGI web interface to be accessible. Note that for this to work you must have Apache2 installed and configured properly for your Ubuntu system.

Start by installing the apcupsd-cgi package:

sudo apt-get -y install apcupsd-cgi

This will drop several files into /usr/lib/cgi-bin/apcupsd. For this to work you must have CGI enabled in your Apache configuration and the CGI directory should be pointed at /usr/lib/cgi-bin/. The only thing left is to go to the web address: http://localhost/cgi-bin/apcupsd/multimon.cgi

apcupsd-cgi via Webmin

The following changes to a Ubuntu system will allow APCUPSD-CGI web interface to be accessible as a module using webmin. Note that for this to work you must have webmin installed and configured properly for your Ubuntu system. Note: To install webmin in under 2 minutes click http://www.webmin.com/deb.html and follow the instructions under Using the Webmin APT repository.

Start by installing the apcupsd-cgi package with:

sudo apt-get install apcupsd-cgi

This will drop several files into /usr/lib/cgi-bin/apcupsd. Then copy the contents of /usr/lib/cgi-bin/apcuspd/ to /etc/apcupsd/:

sudo cp /usr/lib/cgi-bin/apcupsd/*.cgi /etc/apcupsd/

External links


apcupsd (last edited 2017-07-19 04:06:32 by 90)