- All
- Sun
APC UPS on OpenSolaris (apcupsd)
One of the best consumer UPS manufacturer on the market is APC. They make great products that can interface nicely with any UNIX-based system, whether it be Linux, BSD, or Solaris. Using their daemon (apcupsd), you can download the source and create a nice link-up with your UPS so you can be notified anytime your power goes out (or if you accidentally unplug it)

My home model is the APC ES550 which is USB-based and has a weird USB->RJ45 cable to link a computer with the UPS. Let me explain how to get this running with OpenSolaris with at least this model.
First you will need the latest apcupsd tarball located on Source Forge. Then, follow some standard compiling directions:
$ tar zxvf apcupsd-3.14.4.tar.gz && cd apcupsd-3.14.4
$ ./configure --enable-usb
$ make
# make install
If your model is USB-based, you need the enable-usb flag with the configure script. Now when you make, however, it will most likely fail with the following error.
libusb.h:9:34: /usr/sfw/include/usb.h: No such file or directory ... lots of errors ...
'make' fails on OpenSolaris because by default it is missing a usb.h header file located in /usr/sfw/include. This can be retrieved by running this command inside that directory as root.
# wget http://src.opensolaris.org/source/raw/sfw/usr/src/lib/libusb/inc/usb.h
Binaries are stored inside /etc/opt/apcupsd/sbin.
The file apcupsd.conf is needed to configure this USB device. Two lines that say the following must be included in this file.
UPSCABLE usb UPSTYPE usbDelete any other UPSCABLE/UPSTYPE lines. The apcupsd.conf file documents other types of APC UPS devices as well, usually those that rely on serial as opposed to usb.
Now, you should be able to run the daemon and you can verify that it will notify you by simply pulling the plug on the UPS. If you modify your root alias in /etc/mail/aliases the UPS will send you an e-mail when the power goes out. This sounds handy if I'm campus and I lose the electricity in my apartment, so I'll have plenty of time to power off my machine remotely.
Posted by Paul Johnson
[Sun] ( July 28, 2008 11:44 AM )
Permalink
| Comments[12]



Unless you have your cablemodem and router plugged into the UPS you'll likely not get into your system to do so.
apcupsd also has the ability to monitor the remaining power in the UPS and shut down your system automatically if the batteries go below a certain threshold.
Posted by Phillip Wagstrom on July 28, 2008 at 02:34 PM MDT #
Yep, you must have a modem and router both plugged in to survive an outage, but in the event of the power going out, my Internet connection stays afloat. apcupsd is a neat toy.
Posted by Paul Johnson on July 28, 2008 at 03:35 PM MDT #
1. For those running OpenSolaris Indiana, the required IPS packages for compiling apcupsd with USB support are: SUNWgcc SUNWgmake SUNWsfwhea. The last one gives you usb.h.
2. apcupsd-3.14.4 has a bug that causes 'make install' to fail on Solaris. This is fixed in the latest 3.14.x CVS branch, so presumably a future 3.14.5 or whatever would be fine. To download from cvs, install the SUNWcvs package, then use the following command to download it.
cvs -z3 -d:pserver:anonymous@apcupsd.cvs.sourceforge.net:/cvsroot/apcupsd co -d apcupsd-3.14-cvs -rBranch-3_14 apcupsd
Update it later by simply running 'cvs update' from inside the apcupsd-3.14-cvs directory.
3. Is anyone aware of an OpenSolaris binary package for apcupsd? If not, I might take it on. Any license or other issues would prevent this?
Posted by Mark on September 21, 2008 at 05:31 PM MDT #
I've been trying to get apcupsd running on an OpenSolaris release 2008.05 server as well. Dell hardware, using USB. Running the Device Driver Utility, I can see the UPS, but when I click on that line in the top, it has an Attach Status of Detached.
Rather new to OpenSolaris, though I run a number of Solaris 10 servers at my day job. Nerver did much with USB, though.
Tried compiling the normal tarball, manually copied stuff around. Might have missed something there, though. Tried the CVS release mentioned above, but it won't compile, dying at src/drivers/dumb/dumboper.c with a number of "'class UPSINFO' has no member" errors.
Thoughts on where to head next?
Posted by Joe Barbey on November 20, 2008 at 01:07 PM MST #
You might want to try rolling back to an older package and see if you have any better luck until the next version of the utility is released. This should list all downloads available for apcupsd. I believe the 3.14.3 version should work with 2008.5.
http://sourceforge.net/project/showfiles.php?group_id=54413&package_id=49059
Posted by Paul Johnson on November 20, 2008 at 01:39 PM MST #
Hi, great tutorial thanks for all the information. It installed fine on my opensolaris b101 but i can't run the deamon , is there a special command to do or normaly i would just run apcupsd in a shell?
Thanks
Sam
Posted by Samuel C on January 01, 2009 at 04:24 PM MST #
Finally got 3.14.3 running, though I needed to copy in the apc.h file from 3.14.4 to get it to compile. It kept complaining about FIONBIO not being defined.
I've now got apcupsd watching the USB UPS on solaris, and a windows 2000 server is monitoring the solaris box so it knows when utility power is gone as well.
Good to finally have this thing working right. Tomorrow I'll try the pulling the power to test. Thanks for your help everybody.
Posted by Joe Barbey on January 05, 2009 at 09:23 PM MST #
Hello. My config is somewhat different. I have SUI2200 attached to Win2008 server USB port but would still like to shut down OpenSolaris server when UPS goes down.
I tried installing pbe_agent_705_solaris-x86_jvm.bin as described on APC site but constantly getting:
Loading the installer...
Starting the installer...
Error: A class is missing from the classpath to run this program.
java.lang.NoClassDefFoundError
Unable to start the install wizard.
Is there a "java" command in the path that doesn't start the JRE?
If there is, remove it and try the installer again.
Java is installed, of course. Exporting DISPLAY as root from xterm didn't help either...
Posted by Tonci Grgin on January 14, 2009 at 09:46 AM MST #
Hi to all. I have built package for apcupsd for Solaris 10x86 and OpenSolaris. You can get it from: http://kosjenka.srce.hr/~jsosic/BTW/
It uses SMF, and only problem I have is that after init 0, apcupsd doesn't kill the power :( I don't know if it's a Solaris problem or just a SMF related problem. I would like some help and someone who can test changes, because server I have with APCUPSD is in production and can't do it.
Thank you.
Posted by Jakov on April 22, 2009 at 07:18 AM MDT #
Jakov.
After my problems with "official" APC agent, I built APCUPSD on fully updated OpenSolaris box and it just works. I did several tests confirming this to adjust parameters as my APC SUI2200 is powering telephony and such (wanted to leave enough power).
Posted by Tonci Grgin on April 22, 2009 at 07:34 AM MDT #
Yes, it works out of the box. But it uses old-style SysV init scripts. I want it to use SMF if possible, and I've written manifest.
My only problem is that after init 0, it does not run the command 'apccontrol killpower'.
Posted by Jakov on April 22, 2009 at 07:38 AM MDT #
Jakov, things are a bit hectic around here lately so I don't have time to look into this further. Later maybe.
Posted by Tonci Grgin on April 30, 2009 at 04:38 AM MDT #