In a previous post it was described how to setup and monitor a UPS dedicated to your Ubuntu workstation computer (STANDALONE mode).
There is also another post about the use of apcupsd, an Open Source solution to monitor your APC UPS, which is connected to your Ubuntu workstation computer (STANDALONE mode).
In some cases you want your UPS to protect more than one computer (MASTER-SLAVE mode). apcupsd is a great solution in case of APC UPS. In my case, I use an APC UPS (“APC Back UPS BR1500GI RS 1500VA (LI)”) which is physically connected via USB with an Ubuntu file and backup server (host name atlas, IP 192.168.1.52 – the MASTER computer). But I also want my UPS to protect my Ubuntu workstation (host name athena, IP 192.168.1.51 – the SLAVE computer).
It is very important the network switch to be powered by the UPS (so the apcupsd NIS server to be functional in case of outage).
See the graph in the top of the article, which describes my hardware setup.
Installation
In all computers, MASTER and SLAVE(S), open a terminal and type
sudo apt-get install apcupsd
See more details in this post.
Configuration ON MASTER COMPUTER
STEP 1 – Edit main configuration file
First, create a backup of main configuration file:
sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.bak
Using your favorite text editor (nano in my case):
sudo nano /etc/apcupsd/apcupsd.conf
Find and edit
- UPSCABLE, UPSTYPE, DEVICE, POLLTIME
- BATTERYLEVEL and MINUTES
In most models, the following changes are enough.
## apcupsd.conf v1.1 ##
#
# for apcupsd release 3.14.12 (29 March 2014) - debian
#
# "apcupsd" POSIX config file
#
# ========= General configuration parameters ============
#
...
UPSCABLE usb
...
UPSTYPE usb
...
#DEVICE /dev/ttyS0
# POLLTIME <int>
# Interval (in seconds) at which apcupsd polls the UPS for status. This
# setting applies both to directly-attached UPSes (UPSTYPE apcsmart, usb,
# dumb) and networked UPSes (UPSTYPE net, snmp). Lowering this setting
# will improve apcupsd's responsiveness to certain events at the cost of
# higher CPU utilization. The default of 60 is appropriate for most
# situations.
#POLLTIME 60
#
# ======== Configuration parameters used during power failures ==========
#
# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
# the first that occurs will cause the initation of a shutdown.
...
# If during a power failure, the remaining battery percentage
# (as reported by the UPS) is below or equal to BATTERYLEVEL,
# apcupsd will initiate a system shutdown.
BATTERYLEVEL 30
...
# If during a power failure, the remaining runtime in minutes
# (as calculated internally by the UPS) is below or equal to MINUTES,
# apcupsd, will initiate a system shutdown.
MINUTES 10
#
# ==== Configuration statements for Network Information Server ====
#
# NETSERVER [ on | off ] on enables, off disables the network
# information server.
...
NETSERVER on
# NISIP <dotted notation ip address>
...
NISIP 0.0.0.0
STEP 2 – Edit etc/apcupsd/hosts.conf
Using your favorite text editor (nano in my case):
sudo nano /etc/apcupsd/hosts.conf
This file contains the computers, protected by this UPS. In my case:
# Network UPS Tools - hosts.conf
#
# This file does double duty - it lists the systems that multimon will
# monitor, and also specifies the systems that upsstats is allowed to
# watch. It keeps people from feeding random addresses to upsstats,
# among other things. upsimage also uses this file to know who it
# may speak to. upsfstats too.
#
# Usage: list systems running upsd that you want to monitor
#
# MONITOR <address> "<host description>"
MONITOR 192.168.1.52 "Backup server"
MONITOR 192.168.1.51 "Athena workstation"
STEP 3 – Edit /etc/default/apcupsd
Using your favorite text editor (nano in my case):
sudo nano /etc/default/apcupsd
set:
...
ISCONFIGURED=yes
...
STEP 4 – Finally, restart apcupsd
Open a terminal and type:
sudo systemctl restart apcupsd.service
Configuration ON SLAVE COMPUTER(S)
STEP 1 – Edit main configuration file
First, create a backup of main configuration file:
sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.bak
Using your favorite text editor (nano in my case):
sudo nano /etc/apcupsd/apcupsd.conf
Find and edit
- UPSCABLE, UPSTYPE, DEVICE, POLLTIME
- BATTERYLEVEL and MINUTES
In most models, the following changes are enough.
## apcupsd.conf v1.1 ##
#
# for apcupsd release 3.14.12 (29 March 2014) - debian
#
# "apcupsd" POSIX config file
#
# ========= General configuration parameters ============
#
...
UPSCABLE ether
...
UPSTYPE net
...
# set the MASTER COMPUTER IP (192.168.1.52 in my case)
# The default port for apcupsd is 3551
DEVICE 192.168.1.52:3551
# POLLTIME <int>
# Interval (in seconds) at which apcupsd polls the UPS for status. This
# setting applies both to directly-attached UPSes (UPSTYPE apcsmart, usb,
# dumb) and networked UPSes (UPSTYPE net, snmp). Lowering this setting
# will improve apcupsd's responsiveness to certain events at the cost of
# higher CPU utilization. The default of 60 is appropriate for most
# situations.
POLLTIME 10
...
#
# ======== Configuration parameters used during power failures ==========
#
# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
# the first that occurs will cause the initation of a shutdown.
...
# If during a power failure, the remaining battery percentage
# (as reported by the UPS) is below or equal to BATTERYLEVEL,
# apcupsd will initiate a system shutdown.
BATTERYLEVEL 40
...
# If during a power failure, the remaining runtime in minutes
# (as calculated internally by the UPS) is below or equal to MINUTES,
# apcupsd, will initiate a system shutdown.
MINUTES 15
#
# ==== Configuration statements for Network Information Server ====
#
# NETSERVER [ on | off ] on enables, off disables the network
# information server.
...
NETSERVER on
# NISIP <dotted notation ip address>
...
NISIP 0.0.0.0
STEP 2 – Edit /etc/default/apcupsd
Using your favorite text editor (nano in my case):
sudo nano /etc/default/apcupsd
set:
...
ISCONFIGURED=yes
...
STEP 3 – Finally, restart apcupsd
Open a terminal and type:
sudo systemctl restart apcupsd.service
Configuration synopsis
Differences in MAIN configuration file between MASTER and SLAVE setup:
Parameter | Master | Slave |
---|---|---|
UPSCABLE | usb | ether |
UPSTYPE | usb | net |
DEVICE | #DEVICE … | master-ip:3551 |
POLLTIME | 60 | 10 |
CAUTION: Pay attention to set BATTERYLEVEL and MINUTES properly, so in case of outage SLAVE(S) to shutdown before MASTER.
View logs
To view apcupsd logs, open a terminal and type:
tail /var/log/apcupsd.events
Command line interface
To get information about your UPS status, use the command:
apcaccess
Output in MASTER (host name “atlas”)
APC : 001,036,0873
DATE : 2016-12-15 20:08:22 +0200
HOSTNAME : atlas
VERSION : 3.14.12 (29 March 2014) debian
UPSNAME : atlas-m
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2016-12-15 20:02:22 +0200
MODEL : Back-UPS RS 1500G
STATUS : ONLINE
LINEV : 223.0 Volts
LOADPCT : 16.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 42.8 Minutes
MBATTCHG : 30 Percent
MINTIMEL : 10 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 176.0 Volts
HITRANS : 294.0 Volts
ALARMDEL : No alarm
BATTV : 27.2 Volts
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 3Q1106X37131
BATTDATE : 2012-07-05
NOMINV : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 865 Watts
FIRMWARE : 878.L4 .I USB FW:L4
END APC : 2016-12-15 20:08:24 +0200
Output in SLAVE (host name “athena”)
APC : 001,037,0934
DATE : 2016-12-15 20:07:43 +0200
HOSTNAME : athena
VERSION : 3.14.12 (29 March 2014) debian
UPSNAME : atlas-m
CABLE : Ethernet Link
DRIVER : NETWORK UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2016-12-15 20:07:43 +0200
MASTERUPD: 2016-12-15 20:07:43 +0200
MASTER : 192.168.1.52:3551
MODEL : Back-UPS RS 1500G
STATUS : ONLINE SLAVE
LINEV : 224.0 Volts
LOADPCT : 12.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 53.6 Minutes
MBATTCHG : 40 Percent
MINTIMEL : 15 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 176.0 Volts
HITRANS : 294.0 Volts
BATTV : 27.2 Volts
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000408
SERIALNO : 3Q1106X37131
BATTDATE : 2012-07-05
NOMINV : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 865 Watts
FIRMWARE : 878.L4 .I USB FW:L4
END APC : 2016-12-15 20:07:46 +0200
Web interface
apcupsd offers a handy web interface to monitor your UPS. You have to install it in MASTER COMPUTER and optionally in SLAVE(S). To install it, open a terminal and type
sudo apt-get install apcupsd-cgi
Of course, a web server is needed to use the web interface. For example, to install Apache (if not installed):
sudo apt-get install apache2
To access web interface, point your browser to
http://COMPUTER-IP/cgi-bin/apcupsd/multimon.cgi
Here is the main page:
To get details, click the “Local host” link. The “All data” link
is similar to apcaccess
output. See screenshots in
this post.
Graphical interface (gapcmon)
Unfortunately gapcmon is not yet available for latest Ubuntu versions (as Xenial 16.04 etc). See here for details.
However, this is how the main screen looks like:
See more screenshots in this post.
Test your UPS
See details in this post.
Entrepreneur | Full-stack developer | Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects.