-- 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

  • apt-get install apcupsd

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
    • ISCONFIGURED=yes

  • Make the following changes to /etc/apcupsd/apcupsd.conf
    • UPSCABLE usb
    • UPSTYPE usb
    • DEVICE
  • Start service
    • service apcupsd start

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:
    • ISCONFIGURED=yes
  • Make the following changes to /etc/apcupsd/apcupsd.conf
    • UPSCABLE usb
    • UPSTYPE usb
    • DEVICE
    • NETSERVER on*
      • This is default
    • 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
    • ISCONFIGURED=yes
  • 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

  • service apcupsd start

Configuration and Diagnostics using apctest

  • You must stop apcupsd when running tests
    • service apcupsd stop
  • Start apctest
    • 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
    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

Stopping service

  • service apcupsd stop

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
  1. changeme, - notification of a failed battery
  2. commok - notification of resumed communication between the UPS and the server
  3. commfailure - notification of failed communication between the UPS and the server
  4. offbattery - notification of main power loss
  5. 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:

  1. SYSADMIN - a list of email recipients separated by commas
  2. APCUPSD_MAIL - the email application. In this example it is "sendemail", but it could be another email app
  3. MSG - subject of the emails
  4. ( ) - 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.
  5. | $APCUPSD_MAIL -u "$MSG" -f plg5@cs.uwaterloo.ca -t $SYSADMIN -s connect.uwaterloo.ca:25
The last line is parsed as:
  1. -u is followed by the subject message
  2. -f is the sending email address. Note this is a fake address.
  3. -t the recipient list
  4. -s the mail server and port
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2015-09-02 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback