Because we use APC UPSes, it is nice if they can shut down our PCs when power has failed and if we can see the condition of the UPS battery for maintenance. However, APC does not have any software for Linux, that I have seen. I did come across a couple of nice links however, that explains exactly how to do it, and I will share them here, with some excerpts from those web pages. NOTE TO SELF – it was 3am when you did this and you are editing it at 10pm: check it in the morning on another system and fix anything you remembered wrong.
The download link on source forge: http://sourceforge.net/projects/apcupsd/. When you are done you can view your UPS with your web browser at http://localhost/cgi-bin/apcupsd/multimon.cgi
Problem: some unsatisfied dependencies, at least in the webmin install part. You must use dpkg -f install xxxxxxx to grab them.
The Ubuntu Wiki page has detailed instructions, which worked for me: https://help.ubuntu.com/community/apcupsd. It also has instructions for viewing the UPS condition in real time with your web browser and with Webmin. This had the same information http://www.cyberciti.biz/faq/debian-ubuntu-centos-rhel-install-apcups/. Another good reference was apcupsd web site at http://www.apcupsd.org/ and the Webmin site at http://webmin.com/. Before you can use apt-get to install you need to add the repositories to your sources. One way to do so is like this:
nano /etc/apt/sources.list
then paste in these two lines:
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
And in terminal (as root) install the required key
cd /root
wget http://www.webmin.com/jcameron-key.asc
apt-key add jcameron-key.asc
After you have added the sources it is basically beginner stuff:
apt-get update
apt-get install apcupsd
(if you have Apache2 installed and want to view your UPS with your web browser)
apt-get install apcupsd-cgi
(if you want webmin, then also do the following — otherwise skip it)
apt-get -f install webmin
cp /usr/lib/cgi-bin/apcupsd/*.cgi /etc/apcupsd/
Open Webmin in your browser by going to https://localhost:10000
Menu bar on the left “Webmin->Webmin Configuration”
“Webmin Modules”
“Third party module from” and enter http://diego.caravana.to/wp-content/apcupsd0.812.wbm.gz into the address box, then click on the install module button
To use it find “APC UPS Daemon” under “Other” from the left menu in Webmin
Then configure the /etc/apcupsd/apcupsd.conf file by changing three lines and commenting out a fourth line
- nano /etc/apcupsd/apcupsd.conf
- UPSNAME homeups1 (or whatever name you want)
- UPSCABLE usb
- UPSTYPE usb
- #DEVICE (put the # in front to comment out)
Then edit /etc/default/apcupsd and change the line ISCONFIGURED=no to ISCONFIGURED=yes.
- nano /etc/default/apcupsd
- ISCONFIGURED=yes
You might then give it a: “service apcupsd start” or if you don’t have “service” on your system then use “/etc/init.d/apcupsd start” and use “apcaccess status” in terminal to see the status of your APC UPS.
If you have Apache2 installed, you can see your UPS stastus with your web browser, much like using phpMyAdmin or Webmin. In fact, you can use Webmin. Look at the directions on the Ubuntu Wiki at https://help.ubuntu.com/community/apcupsd by Spart.
The user manual can be found (html and pdf) at http://www.apcupsd.org/manual/manual.html
—
NOTE: On one system I couldn’t get communications to work right. The fix was here at http://flossexperiences.wordpress.com/2008/10/26/configuring-apcupsd/
sudo /sbin/apcaccess status
I ran into this error
Error contacting apcupsd @ localhost:3551: Connection refused
It took me sometime to realize I had to add some info. of the same at /etc/hosts.allow for this to function . So again first take a backup of the hosts.allow file.
$ sudo cp /etc/hosts.allow /etc/hosts.allow.orig
Then do the change therein by doing :-
$ gksudo gedit /etc/hosts.allow
and adding just this line :-
apcupsd: 127.0.0.0/255.0.0.0
Now when I ran the above command again it worked :-
To test the APC UPS, use apctest. You must stop the service apcupsd before typing apctest.
NOTE: 20160211 I noted for little time now, this has not worked! The fix was revealed by finite9 on http://ubuntuforums.org/showthread.php?t=1778274&page=2
It's because of the new localhost IP address that's appeared in 12.10 (I just noticed it but maybe it came in previous versions), plus the default settings in apcupsd.conf need changing. I have a USB device, which means the the DEVICE parameter _must_ be commented out, so that autodetection os the usb device works, otherwise, it's trying to tie the ups to a specific device that's not going to work. Secondly, due to the new 127.0.1.1 address in /etc/hosts, the NISIP setting needs changing. It doesn't work to change it to 127.0.0.1 without changing hosts file, but you can set it to 0.0.0.0, then apcaccess will work again. Otherwise, you can turn off NETSERVER access completely if you don't need to access your UPS over the network (which I doubt most home owners do). So: sudo vi /etc/apcupsd/apcupsd.conf UPSCABLE usb UPSTYPE usb NISIP 0.0.0.0 sudo service apcupsd restart cat /var/log/apcupsd.events 2012-12-20 13:14:39 +0100 apcupsd exiting, signal 15 2012-12-20 13:14:39 +0100 apcupsd shutdown succeeded 2012-12-20 13:14:51 +0100 apcupsd 3.14.10 (13 September 2011) debian startup succeeded sudo apcaccess status
This worked for me.