powstatd install and configururation HOWTO for sme server
for sme v5.5, 5.6, 6.0 & 7.0
The contrib & this procedure has been tested on sme server v5.5, v5.6, v6.0 and v7.0 unsupported developer releases.
Revised: 1 April 2006
Note re installation on sme 7.0 - The rpms appear to install & function correctly on sme 7.0. Note that as the db locations have changed the db entry for powstatd is not created by the rpm. You will need to manually enter the powstatd entry in the configuration database as per the instructions below.
Information:
The contents of this document are based on the readme by Charlie Brady who wrote the contrib, & on the powstatd man file.
The first 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.
The second revision (3 March 2003) includes the db configuration command to enable powstatd at start up, additional information about cables from the apcupsd reference manual, additional information about test responses for various APC UPS's, reference to manual pages for powstatd, amended reference to the latest rpm, and minor spelling changes & corrections.
The third revision (3 February 2004) includes new download site locations, confirms support for sme server v6.0, includes information about database entry requirements for sme v6.0, includes procedure to fix an incorrect configuration using the template process, includes a workaround for incorrect shutdown during power failure, has additional configuration information for Sola & Powerware UPS's and other minor changes & corrections.
This document is intended for users wanting to install and configure a UPS on a sme server, and provides users with enough information to configure powstatd for just about any type of UPS with a serial port connection.
Preparation:
- You need either a smart UPS or a "dumb" UPS with a serial connection. 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 UPS's.
- general information about cables and pin connections can be found in the Cables section of the APCUPSD Reference Manual, see http://www.apcupsd.com/index.html
and http://www.apcupsd.com/manual/cables.html
- the UPS batteries need to be fully charged
- install your UPS physically but connect the power outlet to a lamp or your monitor, not your sme box.
- although this information is not directly applicable to powstatd, there is information about test responses from various APC UPS's available at http://www.apcupsd.com/manual/apctest.html
Install the software:
Install as root or using sudo:
rpm -Uvh ftp://ftp.ibiblio.org/pub/linux/distributions/e-smith/contrib/CharlieBrady/RPMS/i386/powstatd-1.4.1-1.i386.rpm
then
rpm -Uvh ftp://ftp.ibiblio.org/pub/linux/distributions/e-smith/contrib/CharlieBrady/RPMS/noarch/e-smith-powstatd-0.1.0-04.noarch.rpm
Alternatively download the rpms to an empty folder and from that folder 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.
Note: If you are upgrading an existing server from sme v5.5 or v5.6 to v6.0 you should check the database entry is correct.
The entry in the /home/e-smith/configuration file should have the "powstatd=service|" type field rather than the older "UPS=..." entry eg
powstatd=service|fail|cts,1|init0|dtr|init1|rts|kill|dtr,1|low|dcd,1|status|enabled|watch|ttyS0
(note that this entry will be different depending on your particular UPS and configuration)
To check this do
grep powstatd /home/e-smith/configuration
If necessary you may need to do
rpm -Uvh --force e-smith-powstatd-0.1.0-04.noarch.rpm
and this will automatically convert the db entry
Existing entries will be automatically converted if you upgrade from an earlier version of the rpm.
Always check for the latest versions of rpms as these are works in progress and being constantly updated when new config information becomes available.
Configuring powstatd:
Now review
/usr/share/doc/e-smith-powstatd-0.1.0/README
to see if your UPS is listed.
Here is an excerpt from the README showing the configuration settings for different UPS's.
To configure for a CyberPower 99 UPS, do:
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 dtr init1 rts fail cts,0 kill dtr,1 low dcd,1
To configure for an APC UPS, do:
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 rts init1 dtr fail dsr,0 kill rts,1 low cts,0
To configure for an APC BackUPS 650 UPS with a 940-0020C cable, do:
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init1 rts init0 dtr fail cts,1 kill dtr,1 low dcd,1
To configure for a Powertech PC-Fit 600, do:
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 dtr init1 rts fail cts,0 kill dtr,1 low dcd,0
To configure for a Sola305 with cable INT-0051
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 rts init0 rng init0 dsr init1 dtr fail cts,0 low dcd,0 kill rts,1
To configure for a Sola305 with cable INT-0025C
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 dsr init0 rng init0 dtr init1 rts fail cts,0 low dcd,0 kill dtr,1
To configure for a Powerware3110 with cable INT-0025C
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 dsr init0 rng init0 dtr init1 rts fail cts,0 low dcd,0 kill dtr,1
If your UPS is listed above or in the README, run the command as shown to modify the sme database for your UPS configuration - if it's not then use a config that is close for testing. eg
/sbin/e-smith/db configuration set powstatd service status enabled \
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/expand-template /etc/powstatd.conf
or
/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
Note: 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 (this topic is beyond the scope of this doc, see cable notes below).
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 status enabled \
watch ttyS0 init0 rts init1 dtr fail dcd,0 kill rts,1 low cts,0
/sbin/e-smith/expand-template /etc/powstatd.conf
or
/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)
Setting to work:
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/signal-event console-save
/etc/rc.d/init.d/powstatd start
shutdown and connect your sme box to the UPS power outlet and reboot.
That's it.
Possible problems:
If while testing you wish to manually stop powstatd then do
/etc/rc.d/init.d/powstatd stop
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 that may occur 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 configuration.
If you cannot do this, then you should reboot in single user mode, and then modify the configuration.
To start up in single user mode, press Ctrl X when you see the e-smith, Mitel or sme logo appear on the screen after a reboot. This will start the server at a lilo text prompt.
For sme version 6.0
Type:
Mitel-SME-up
or
Mitel-SME-smp
For sme version 5.6
Type:
Mitel-SME single
or
Mitel-SME 1
For sme version 5.5, 5.1.2, 5.0, 4.1.2 or earlier
Type:
esmith single
or
esmith 1
This boots the server into single user mode.
Once you have restarted your server you need to correct the database entry and expand the template.
First of all stop powstatd running with
/etc/rc.d/init.d/powstatd stop
then determine the correct configuration and issue the correct configuration
command to update the database eg
/sbin/e-smith/db configuration set powstatd service status enabled \
watch ttyS0 init0 rts init1 dtr fail dsr,0 kill rts,1 low cts,0
with the values corrected as required.
then do
/sbin/e-smith/expand-template /etc/powstatd.conf
or
/sbin/e-smith/signal-event console-save
then do
/etc/rc.d/init.d/powstatd start
Note that the configuration settings are saved in /home/e-smith/configuration
and these are written to the /etc/powstatd.conf file when the template is expanded.
Do not edit /etc/powstatd.conf directly as changes will be overwritten by the templating process next time you do a console-save.
Then reboot (press Ctrl Alt Del) and check that your server starts up correctly with powstatd running.
If you experience a problem getting powstatd to start after a reboot of the server
ie you see the message
powstatd [DISABLED]
then at a command prompt do
/sbin/e-smith/db configuration setprop powstatd status enabled
If you have a problem with the UPS and server not shutting down correctly during power failure and receive a message
"shutting down UPS service"
for approximately 40 seconds until the UPS switches off, try the following.
pico /etc/rc.d/init.d/powstatd
find the line that reads
powstatd -k
(it's about 10 lines from the end)
Add an & to the end of the powstatd -k command making the line read
powstatd -k &
Save the changes
Ctrl o
Ctrl x
This will force the kill command to run in the background so that it doesn't hold up the rest of the shutdown.
From a Forum post by Darrell Lewis 24 April 2003
Further information:
For further information about powstatd see
/usr/share/doc/e-smith-powstatd-0.1.0/README
and
at a command prompt do
man powstatd
press q to quit the manual pages
(this assumes powstatd and the man rpm's are installed)
Extract from dev-info mailing list re Cable pinouts:
(Note this section is included for general interest and may be of assistance to users who cannot get powstatd and their UPS to talk to each other due to an incorrect cable. RM).
http://www.mail-archive.com/devinfo@lists.e-smith.org/msg05404.html
From: Graeme Robinson
Subject: Re: [e-smith-devinfo] UPS brand recommendations?
Date: Mon, 17 Sep 2001 14:41:45 -0700
--------------------------------------------------------------------------------
Any UPS with serial cable link will do - make your
decision based on the power demands of the system.
I've also recently made a polarity map for a 9 pin serial cable that works
with e-smith - theoretically it can be used to 'fix' a cable that
doesn't work out of the box ( the majority of win-ready cables it seems),
either by breaking out the soldering iron or modifying the
source code for powstatd and recompiling for the different
pins.
I've made a diagram for this but the ascii version FYI is:
(+) (-)
1 <-> 9
4 <-> 3
5 <-> 5
7 <-> 3
8 <-> 1
- numbering is left-right top-bottom looking at a 9pin fitting with the
row of 5 pins/holes above the row of 4.
http://www.mail-archive.com/devinfo@lists.e-smith.org/msg05408.html
From: Richard Ford
Subject: Re: [e-smith-devinfo] UPS brand recommendations?
Date: Mon, 17 Sep 2001 19:17:04 -0700
--------------------------------------------------------------------------------
The cable it turns out during some testing is to do with the mode of the
UPS.
A "smart serial UPS" needs a different cable than a "dumb serial" UPS.
We had a APC Smart UPS 1000 and the cable that came with it (Dark grey)
would make a signal appear with powestatd even if the other end wasn't
plugged into anything - that is - just a loose cable plugged into the serial
port of the server.
I have used a dumb APC model (Back UPS Pro SI) with powerstatd and Graeme's
howto and had no problems at all - apart from getting the init string
correct.
To use powerstad with a smart UPS - you will need to plug the UPS into a
machine running APC's Power chute (Windows or Linux) and set the system to
"dumb" mode. This saves it into the nvram of the UPS. Then you can hook
the UPS up to a server with powerstatd and a dumb serial cable (Light grey)
and all should work. Note that last step - I am about to test this week -
it should work given all the info I could get from APC on the phone.
Cheers,
Richard.
Ray Mitchell
1 April 2006
mitchellcpa_AT_yahoo.com.au