Here is a revised version of the HOWTO, with minor corrections.
To be posted to the Contrib HOWTO site asap.
Regards
Ray Mitchell
HOWTO install and configure powstatd on mitel sme v5.5 & 5.6:
Revised: 26 February 2003
Note: The contents of this document are based on the readme by Charlie Brady who wrote the contrib, & on the powstatd man file.
The revised document (released 18 November 2002) is copied from the original by Graeme Robinson and modified as required to include the new updated rpms, installation instructions to suit the revised rpms and other minor additions.
This latest revision (26 February 2003) includes the db configuration command to enable powstatd at start up, and additional information about cables from the apcupsd reference manual and minor spelling corrections
This revised procedure has been tested on a mitel sme server v5.5 with update 2, and on a v5.6 unsupported developer release.
This document is intended for an audience wanting to install and configure a UPS on a mitel sme server, probably for the first time.
Preparation:
-=-=-=-=-=-
- You need a smart UPS or a UPS with some kind of serial connection for this document to make sense. Note that some UPS's will only signal battery failure, not the LOW state - unless the documentation for your UPS tells you this (I'm yet to see it) you can only test this by running the UPS battery down under test conditions.
- You will also need a serial cable for your system, which is often a purchaseable addon component for many UPSs.
- information about cables and pin connections can be found in the Cables section of the APCUPSD Reference Manual, see
http://www.apcupsd.com/index.htmland
http://www.apcupsd.com/manual/cables.html- the UPS needs to be fully charged
- install your UPS physically but connect it to a lamp or your monitor, not your sme box.
Install the software:
-=-=-=-=-=-=-=-=-=-=-
Install as root or using sudo:
rpm -Uvh
ftp://ftp.e-smith.org/pub/e-smith/contrib/CharlieBrady/RPMS/i386-RH7.0/ powstatd-1.4.1-1.i386.rpm
then
rpm -Uvh
ftp://ftp.e-smith.org/pub/e-smith/contrib/CharlieBrady/RPMS/noarch/e-smith-powstatd-0.1.0-01.noarch.rpm
Alternatively download the rpms to an empty folder and do
rpm -Uvh *.rpm
Note: If you have already downloaded an earlier version of the powstatd-1.4.1-1.i386.rpm (pre 11 November 2002), ensure you download the latest version as it has been recompiled to run with more recent versions of the rpm command.
Note: If you are updating from an earlier version of e-smith 4.1.2 or sme 5.1.2 server and updating a previous installation of powstatd, then the installation of the new e-smith-powstatd rpm will convert the configuration db setting from UPS to powstatd in the /home/e-smith/configuration file.
If necessary you may need to do
rpm -Uvh --force e-smith-powstatd-0.1.0-01.noarch.rpm
and this will automatically convert the db entry
Configuring powstatd:
-=-=-=-=-=-=-=-=-=-=-
Now review
/usr/share/doc/e-smith-powstatd-0.1/README
to see if your UPS is listed.
If it is you're in luck and can run the command in the README as configured to modify the e=smith database for your UPS configuration - if it's
not use a config that is close for testing. eg
/sbin/e-smith/db configuration set powstatd service \
watch ttyS0 init0 rts init1 dtr fail dsr,0 kill rts,1 low cts,0
note: get your com port right (com1=ttyS0, com2=ttyS1)
to activate this config do
/sbin/e-smith/signal-event console-save
Now run a test:
powstatd -t
If your config is right it will report OK with power to the UPS connected, then change state to FAIL within 10-30secs after you
remove mains power from the UPS, then switch to LOW when the battery has run down.
eg:
CTS DSR DCD RNG DTR RTS STATUS
1 0 1 0 1 0 OK
1 0 1 0 1 0 OK
NB: using powstatd -t won't cause your system to shutdown - it's test mode.
To cancel test mode press Ctrl c
If your config is wrong then the initial power-on state will report FAIL or LOW. No problem - we can now modify the config and test again.
Modifying a config correctly:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
If your system reports FAIL or LOW instead of OK with full mains power to the UPS do these things in this order:
1. make sure you have the correct com port selected and that all cables really are connected!
2. look again at your test output. The first 4 columns refer to input coming from the UPS - the will be either zero's or one's.
If they are all zero's and you are sure of 1. then the cable you are using is the wrong one & won't work with powstatd. See your
supplier and get another that's compatible (what this means is beyond the scope of this doc).
3. If there is some input signal coming in (ie one or more of the CTS, DSR, CDC, RNG are signalling '1') in test mode,
make a note of the state change from power on to power off and then battery low. This last change may take some time as running the power
down on a big UPS without significant load can take a while - don't overload it though as the UPS will just shutoff.
You can then modify the configuration command appropriately
eg. (the columns may not line up too well)
For:
CTS DSR DCD RNG DTR RTS STATUS
1 0 1 0 1 0 OK = full mains power
1 0 0 0 1 0 FAIL = battery power, |fail|dcd,0|
0 0 0 0 1 0 LOW = low battery power, |low|cts,0|
You would update the config:
/sbin/e-smith/db configuration set powstatd service \
watch ttyS0 init0 rts init1 dtr fail dcd,0 kill rts,1 low cts,0
/sbin/e-smith/signal-event console-save
now do powstatd -t again and test state changes by removing power.
Time to go live! (But still not with the server connected!)
/etc/rc.d/init.d/powstatd start
Try removing power from the UPS - you should get an onscreen announcement that power has failed and shutdown will happen in x minutes.
Reconnect the power and you should get a message saying power has been restored and shutdown cancelled.
If you wish to alter the default time before the UPS shuts down after power has failed, you will need to create a custom template. The default time is 2 minutes.
Do
mkdir -p /etc/e-smith/templates-custom/etc/inittab
then do
cp -rp /etc/e-smith/templates/etc/inittab/40powerfail /etc/e-smith/templates-
custom/etc/inittab/
then do
pico /etc/e-smith/templates-custom/etc/inittab/40powerfail
then change the part that says
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
(change the +2 to say +7 if you want the UPS to wait 7 minutes before shutting down after power has failed)
When you are happy with your settings and ready to set powstatd and your UPS working on a live server
then do
/sbin/e-smith/db configuration setprop powstatd status enabled
/sbin/e-smith/signal-event console-save
/etc/rc.d/init.d/powstatd start
shutdown and connect your sme box to the UPS and reboot.
That's it.
Note: the kill command is almost always signalled by RTS 1 so the init state should always be '0', but if you find your UPS shutting down when you first run powstatd in real mode try changing this to '1' and kill to 0.
Another problem you might get if you get the config wrong is the phenomenon of your server shutting down just after it's started up. Try quickly logging in and doing a
shutdown -c
to cancel the shutdown and allow you to modify the config.
If you cannot do this, then try rebooting in single user mode and disable powstatd by renaming /etc/powstatd.conf to something else. Reboot and you should be able to fix the configuration.
To do this press Ctrl X when you see the Mitel logo appear on the screen after a reboot. This will start the server at a lilo text prompt.
Type:
esmith single
or
esmith 1
This boots the server into single user mode.
Then do
mv /etc/powstatd.conf /etc/powstatd.conf.old
then reboot (press Ctrl Alt Del) and redo the configuration setup with the new (correct) configuration parameters.
Ray Mitchell
26 February 2003
mitchellcpa@yahoo.com.au