--
MikeGore - 04 Mar 2013
APCUPSD setup and networking notes for Ubuntu
This document contains minimal basic instructions for using a standalone or cluster managed networked UPS. Please See the documentation link for full details.
External documentation
Installation Linux
Installation Windows
Configuration Linux and Windows
- Windows and Linux use the same configuration files and settings
- Windows install will automatically start apcupsd.conf in an editor during install (see following sections)
- Windows instaler will interactively ask if you want the service to run - let it pick the defaults
Standalone USB UPS
- Make the following changes to /etc/default/apcupsd
- Make the following changes to /etc/apcupsd/apcupsd.conf
- UPSCABLE usb
- UPSTYPE usb
- DEVICE
- Start service
Network Server
In this example we have two private networks we want to share APC status on
- MEdit: /etc/default/apcupsd and modify as follows:
- Make the following changes to /etc/apcupsd/apcupsd.conf
- UPSCABLE usb
- UPSTYPE usb
- DEVICE
- NETSERVER on*
- NISIP 127.0.0.1 10.0.2.1 192.168.2.1
- The list of clinet IP addresses you will permit to query APCUPSD
- Note: You must always have 127.0.0.1 listed
Network Client
We will listen on the 10.0.2.1 interface example above
- Make the following changes to /etc/default/apcupsd
- Make the following changes to /etc/apcupsd/apcupsd.conf
- UPSCABLE ether
- UPSTYPE net
- DEVICE 10.0.2.1:3551
- POLLTIME 10
- Note: Likely want to poll quickly
Network troubleshooting
- If you use tcpwrappers (ie: /etc/hosts.allow /etc/hosts.deny ) *make sure you have "ALL: 127.0." added in /etc/hosts.allow
- otherwise you will get: Error reading status from apcupsd @ localhost:3551: Connection reset by peer
Running and Testing
Starting service
Configuration and Diagnostics using apctest
- You must stop apcupsd when running tests
- Start apctest
apctest Documentation Summary
- You can view and make configuration changes to the UPS with apctest
- See http://www.apcupsd.com/manual/manual.html#apctest
- You have the following options
- ) Test kill UPS power
- ) Perform self-test
- ) Read last self-test result
- ) View/Change battery date
- ) View manufacturing date
- ) View/Change alarm behavior
- ) View/Change sensitivity
- ) View/Change low transfer voltage
- ) View/Change high transfer voltage
- ) Perform battery calibration
- ) Test alarm
- ) View/Change self-test interval Q) Quit
Stopping service
Getting Status - gives LOTS of detailed information on the UPS state
- service apcupsd status
- apcaccess status
Email Events
Install an Email App
- sudo apt-get install sendemail
Files to Edit
- In /etc/apcupsd find these files
- changeme, - notification of a failed battery
- commok - notification of resumed communication between the UPS and the server
- commfailure - notification of failed communication between the UPS and the server
- offbattery - notification of main power loss
- onbattery - notification that main power has resumed
Edit the Appropriate Config File
- sudo vi /etc/apcupsd/onbattery
cscf-adm@plg5:~$ cat /etc/apcupsd/onbattery
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
# We send an email message to root to notify him.
#
SYSADMIN=cs-rsg-plg@cs.uwaterloo.ca,gboerke@uwaterloo.ca,lfolland@uwaterloo.ca,pabuhr@uwaterloo.ca,asharji@uwaterloo.ca
APCUPSD_MAIL="/usr/bin/sendemail"
HOSTNAME=`plg5.cs`
MSG="UPS for plg5, plg7 and hops Power Failure !!!"
#
(
echo "Subject: $MSG"
echo " "
echo "Main power to the PLG UPS is off"
echo " "
/sbin/apcaccess status
) | $APCUPSD_MAIL -u "$MSG" -f plg5@cs.uwaterloo.ca -t $SYSADMIN -s connect.uwaterloo.ca:25
exit 0
Each of the files are similar in structure. An explanation of the config file:
- SYSADMIN - a list of email recipients separated by commas
- APCUPSD_MAIL - the email application. In this example it is "sendemail", but it could be another email app
- MSG - subject of the emails
- ( ) - within the parenthesis is the body of the email message. It is executed by the shell before sending, hence code such as "/sbin/apcaccess status" can be executed and the results sent.
- | $APCUPSD_MAIL -u "$MSG" -f plg5@cs.uwaterloo.ca -t $SYSADMIN -s connect.uwaterloo.ca:25
The last line is parsed as:
- -u is followed by the subject message
- -f is the sending email address. Note this is a fake address.
- -t the recipient list
- -s the mail server and port