Tripplite Power Daemon for Redhat 4.2

By Mycal Johnson

Disclaimer

The following is instructions and modifications to powerd-2.0 that worked for me. They may not work for you, they might not even work at all. This document and the patch is licenced under GNU GENERAL PUBLIC LICENSE, Version 2, June 1991.

Introduction

I just built a new server based around Red Hat Linux Release 4.2 and wanted it to be as reliable as possible. I wanted it battery backed up with a UPS, and I wanted it to shutdown nicely in case of a power failure.

Cosco had a great deal on Tripp-Lite OmniSmart 675's for under $200. This seemed like a good deal so I purchaced one. It had a monitoring port, cable and supposivly software for all kinds of operating systems. I didn't hold my breath for linux, so I wasn't disapointed when if found that the software didn't support linux.

In the past I've had experiance with Powerd-2.0 so I downloaded the code, compiled it, installed it, and tested it. It didn't work. I hacked on the code for a while, trying to make powerd-2.0 do what I wanted it to do without loosing any of powerd's functionality. The following is what I had to do to get it to work.

The Patch

There have been some changes to Redhat linux that have forced me to change some of the powerd code. The cable that comes with the tripplite UPS's now is not the same as the homemade cables that people used to use. And lastly I don't know if the powerd daemon ever actually worked the way I wanted it to work. The following lists the changes I made in the powerd-2.0 code to work with my Redhat 4.2 / Tripplite UPS with Tripplite cable.

One of the major changes to Redhat linux that will cause powerd-2.0 to fail, is that the powerstatus file has moved from /etc/powerstatus to /var/run/powerstatus. This was a simple change to the powerd-2.0 code.

For some reason in the powerfail routine, it would exit when it should of written to the powerstatus file and notified Init about the power fail. There was this code that would always exicute and return instead of dropping thorough and doing the correct thing. I removed this code.

Once the above two things are fixed, powerd will start to work, but it will not shut off the UPS once we go to run level 0. I had to add some code that actually toggled the UPS powerdown line specifed in powerd.conf instead of just asserting it (powerd documentation claims that it pulses the line, it doesn't).

Finally, if the power comes back on during the shutdown sequence and the powerdown toggle doesn't work, the machine would just sit there forever. I added some code to check if the power is on at run level 0, if the power is on (came back on during shutdown), reboot the machine.

Grab the patch here.

Still to do

There is still a few things that need to be done to to this patch to make Powerd a 100% reliable. The short list is below.

The first is that when powerd is run it always pulses the UPS shutoff line. It should check to see if the UPS is powerd by the mains, and if so not pulse the shutoff line. This is no problem if the ups has power, since it can only be shut off if the mains are out. But it can cause problems if when the machine is coming up the power goes out. Your machine will shut off mid boot, ooouch! This will be my first fix for the next release of the patch.

The second fix is to monitor the battery low line of the UPS and do a shutdown without delay.

Tripplite/Redhat 4.2, Step By Step Guide


Other Info

I've tried this on Redhat 4.2 with a 2.0.31 kernal and a 2.0.30 kernal. It has also been tried with a Tripplite BCPRO 1400 and it works correctly.

When I get time I'll put up the diagrams so you can make your own tripplite cable that is compatible with the above.

Redhat 5.0 Update

Those crazy guys at redhat did it again, on the 5.0 release init uses /etc/powerstatus like it was before the 4.x releases. So for this to work, after you patch the powerd-2.0 code with my patch you must go in and edit power.c and change:
to
for it to work correctly.

More Redhat 5.0 problems

Powerd is now broken again on redhat 5.0 if you upgrade the glibc libraries. I haven't had time to look at this issue yet.

Mycal Labs, Updated May 1998