[CentOS] A problem with power outages

Sat Mar 24 14:37:48 UTC 2012
Ryan Wagoner <rswagoner at gmail.com>

On Sat, Mar 24, 2012 at 7:33 AM, Timothy Murphy <gayleard at alice.it> wrote:

> I have a CentOS-6.2 server in Italy.
> Every few months the server gets into a strange state
> and stops working after a power outage.
> I should say that this does not occur after every power outage;
> I suspect, but have no real evidence for this,
> that if the power comes back too quickly
> then the machine gets confused because it is in the middle of closing down.
>
> If I am in Italy the solution is simple;
> I just press the power button on the machine until it stops
> and then switch it on again, and everything works fine.
>
> I guess that the proper solution is to get a UPS.
> PowerTrust (or Trust) UPS's are available at a reasonable price (€40-€50).
> But I have one question about this solution.
> What if the outage lasts longer than the "life" of the UPS, about 10
> minutes?
> I'd actually like the UPS simply to halt the machine in the proper way
> after say 1 minute; but can this be arranged?
> (If the machine knew it had gone onto UPS,
> this could be arranged fairly simply.)
>
> There is one other possibility.
> There is a Billion modem/router between the ADSL input and the computer.
> This does not seem to have any problem with power outages.
> So if it were possible to send a message to the router
> which would cause the computer to be turned off and on again,
> that might offer an alternative solution.
> One problem with this is that the Italian ISP
> only offers a dynamic IP address.
> I run ddclient with dyndns on the server to translate this
> into a fixed domain-name.
> But this means that any action of this kind would have to be taken
> before the IP address changes.
> I think it usually stays the same for several days,
> but I guess this might not be true if there is an outage at the ISP's site,
> during a big electric storm.
>
> Any suggestions, advice or experience of this problem gratefully received.
>

The solution here is to purchase a UPS. I prefer APC, but there are other
brands that work great. Most connect with USB, but you might find some that
still use serial ports. With the monitoring software loaded, apcupsd for
APC, it will shutdown the computer based on the parameters you configure.
This can be time elapsed on battery, UPS estimated run time remaining, etc.
When the power returns the UPS will wait for time elapsed and minimum
battery charge before turning back on. Usually these are adjustable
parameters in the UPS firmware.

Additionally if your computer BIOS supports configuring the AC recovery
power mode to always on, the computer will start back up. Most default to
last state, which doesn't work as well since shutting down will power off
the computer, which means that last state is off. There are some
workarounds to change the shutdown sequence to just halt and not power off.

Ryan