howto install and configure powstatd on e-smith: Note: the guts of this document is contained in the readme by Charlie Brady who wrote the contrib, & in the powstatd man file. This document is intended for an audience wanting to install and configure a UPS under e-smith, 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. - the UPS needs to be fully charged - install your UPS physically but connect it to a lamp or your monitor, not your e-smith box. Install the software: -=-=-=-=-=-=-=-=-=-=- Install as root or using sudo: rpm -ivh ftp://ftp.e-smith.org/pub/e-smith/contrib/charlieb/RPMS/i386-RH6.2/powstatd-1.4.1-1.i386.rpm then rpm -ivh ftp://ftp.e-smith.org/pub/e-smith/contrib/charlieb/RPMS/noarch/e-smith-powstatd-0.1-03.noarch.rpm (check for later versions first maybe) Configuring powstatd: -=-=-=-=-=-=-=-=-=-=- Now review /usr/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 UPS '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. 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 mails 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 01 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 UPS 'watch|ttyS0|init0|rts|init1|dtr|fail|dcd,0|kill|rts,1|low|cts,0' 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 annoucement 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. shutdown and connect your e-smith 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 then: "try rebooting in single user mode (issue "linux 1" at the LILO prompt) and disable powstatd by renaming /etc/powstatd.conf to something else. Reboot and you should be able to fix the configuration.+ (from the man file).