Monday 7 May 2007

APC UPS shutdown client

UPDATE 24/06/07: installing APC java UPS client on Linux? Have a look at NUT first.

Vendor support for Linux gets better everyday but sometimes they miss the point. I'm happier they do a somewhat sloppy job than not do it at all but there is room for improvement.

Case in point: APC's Powerchute Network Shutdown for Linux 2.2.1. For a daemon whose only job is listening for a "power will be out soon" notice and shutting down the machine, this implementation based on Java is a resource hog.

Many admins will try to install the application via remote console and puzzle at the enigmatic error message:
$ sudo ./pcns221lnx.bin
Password:
Preparing wizard...
Searching for JVM...
Starting the wizard...
Exception in main class "JExpressLoader"

See errors.log for other possible causes.out of disk space?
The log file doesn't help in figuring out that you need X to install the application. On Debian, install the xbase-clients packages and its dependencies; do the same for package sun-java5-jre (it's in the non-free group) if you still haven't done so.

The installer also assumes a RedHat SysV structure (with /etc/rc.d/...). Create this directory if it doesn't exist or you will not have the init script after the install is finished. After a successful installation move the created scripts and links to the correct location on your system.

On a few of my installations, the powerchute.sh script (in /usr/local/bin/PowerChute) was broken; it seemed that some variables weren't substituted by the installer. The correct one looks like this:
INSTALL_PATH="/usr/local/bin/PowerChute"

cd $INSTALL_PATH
#fixes developer.java.sun.com bug id #4059472 -java.net.SocketException: too many files open
ulimit -n 256
nohup /usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/bin/java -Xrs -cp \
./lib/m11.jar:./lib/collections.jar:./lib/jsdk.jar:./comp/AAOL.jar:\
./comp/CommandFileRunner.jar:./comp/EventLogger.jar:./comp/http.jar:\
./comp/Notifier.jar:./comp/Omaha.jar:./comp/PowerSourceAggregator.jar:\
./comp/PSAggregator.jar:./comp/RunTimeVerifier.jar:./comp/Shutdowner.jar:\
./comp/StdPowerSource.jar:./comp/ps/StdPowerSource.jar:\
./comp/shutdownerlets/OSshutdownerlet.jar: com.apcc.m11.arch.application.Application \
1>/dev/null 2>/dev/null &
PROCESSID=$!
echo $PROCESSID > pcns.pid
Last but not least, if you are installing over SSH, make sure your X11 connections are forwarded. The option X11Forward option must be set to "yes" in the server's /etc/ssh/sshd_config. Also, use "-X" when calling ssh, to enable forwarding on the client side (or muck around with your options in ~/.ssh/).

2 comments:

John C said...

A million thanks and a pint of the landlord's finest ale for you. This problem confused the hell out of me. Why would you need X to install something like this? Wouldn't have guessed that at all.

DrM! said...

Hey, man, thank you very much! Like PHPJohn said, if you come to Argentina, the beers are on me!!!