I know a lot of UPS systems come with software to connect to a Windows machine that will allow you to shut down the machine gracefully in the event of a power failure. Does anyone know of a similar system for Unix/Linux machines?
I realize that most newer machines have an option in the BIOS that tells the computer what to do after a power failure but I'd like to try and find a solution that does not involve the server losing power but instead involves the server gracefully shutting down when the UPS tells it power has been cut and also results in the server booting up when power returns.
Where I live we have two kinds of power failures. We have the very short 2-5 seconds blips that occur perhaps once or twice a year and we have the 4+ hour ones that occur once every few years (if at all). The UPS will take care of the short blips (I don't want the server to shutdown until power is off for 5 minutes or UPS reserve hits 30%) and for longer blips I just leave the server powered down until everything comes back up.
Comments
I've found a few in the $100-$200 range that would suit my needs (and work with Unix) but nothing that allows for rebooting when commercial power is restored.
I thought of a work around involving a robot that pushes the power button when power comes back on (when you lose power a relay closes the contacts between the robot and the commercial power. Once commercial power is restored the robot pushes the button and then opens the contacts. The robot would have some sort of capacitor inside of it to hold enough juice to allow it to open the contacts that provide it with commercial power.) The other option would require the UPS itself to have a network port built-in and be able to use the 'wake on lan' function of the server's NIC card.
Using the software, you configure the OS to shutdown if the UPS tells it that it is running on battery. Then the computer will shutdown, and the UPS will stop giving it power. If the BIOS is set to boot the machine when AC power is enabled, then it should boot when the power returns. It's as simple as that. If it doesn't work, then your BIOS just doesn't have that ability.
Personally, almost every motherboard I've had has that feature enabled, and I have to disable it. It's very annoying when you are working on a computer to have it boot as soon as you connect the power supply to the wall.
Just so people know, I recently bought the APC Back-UPS ES 750. It is very nice. First off, it has 10 holes, so you can plug a ton of shit into it. Most importantly it has the master port control feature. The way that works is this. You connect your PC to the master port. Then you connect your monitors, speakers, or other perhipherals to the controlled ports. Then you push the button to enable the master control feature. Now whenever your computer shuts down, or goes to sleep, the UPS will completely cut power to your monitors or speakers. This is big savings on the electric bill if you have speakers or monitors that like to go to sleep, but still use electricity while you are sleeping or away from home. Also, if you have your computer's power management configured properly, you can get it to enter what is known as S3 sleep. S3 sleep is when your computer turns almost all the way off. However, if you push a button, it will wake up almost as quickly as it would if you had merely locked the screen. I've got this working on my computer. it's pretty awesome. I can have my room be completely quiet all night while I sleep, but when I wake up, I don't have to wait for the machine to boot.
As for wake-on-lan, I have never gotten it to work, neither anyone I know has gotten it to work. Also, I do not think you can use wake-on-lan after the power has been cut to the computer. Since the computer then goes mechanically off, instead of the soft-off powerstate where the network card is still powered. It would have to turn 'back on' to that powerstate when power returns, and I don't think that happens without, as Scott mentioned, setting the computer to just power (completely) back up after a power cut.
After doing some more reading online I am finding that a work around is to have your machine go into hibernation when the UPS indicates a power failure AND having that power fail option set in the BIOS. Because the machine is hibernating there will be no data loss when the power is cut and the "power on power fail" setting in the BIOS will bring it all the way back up (not just back in hibernation).
You could use the "Power on at certain time each day" feature if you have it. It won't be as instant but works as a fallback.
Note to self: Do not Google "Automatic turn on".
When UPS reaches 50% (or less) power on battery (no commercial power) PC turns off gracefully. When commercial power is restored PC powers itself up (regardless of UPS battery charge level).
I'm also looking into having a 10Kw standby generator installed at my house that runs on LP or NG.
With a bit of hacking, you can get any DD-WRT router to double as a low-power SNMP server. Considering the insanely low power draw that a router has on a UPS, and the fact that it'll always remain on while the UPS is supplying power, you could have a setup where the UPS is monitored by the router (if it has an SNMP monitor built in). It'd work like so:
On power loss:
1) Power is lost, UPS alarms and signals the router.
2) Router begins monitoring the UPS charge level.
3) At 50% charge, the router signals the server to hibernate.
4) The router remains online until the UPS battery dies.
On power restoration:
1) Router begins to power up immediately. This process will probably take close to a minute.
2) Router queries the UPS, waits until the UPS is charged to a reasonable level before signaling the server to boot. In case the power is promptly lost again, this way there's a safety charge to gracefully re-hibernate with.
3) ???
4) Profit.
I'm well aware of the BIOS option that reboots after a power failure. I have never heard of any BIOS feature that works the way Scott described.
You have a motherboard, and a power supply. When you plug a power supply into the wall, and turn it on, and connect it to a motherboard, it provides power, even if the computer is shut down. This is necessary for the motherboard to draw at least this small amount of power, otherwise how would the power button work? Many modern motherboards have an LED to indicate they are receiving this standby power. You will notice this light turning off after a few seconds if you unplug the computer, or turn the PSU off. When you turn the computer on, the motherboard pulls full power from the PSU. When you turn the computer off, it pulls standby power again. Unless you turn the power supply off, or unless power goes out, the power supply keeps providing this standby power.
The feature I am talking about, which has been on every modern motherboard I've seen works, like this. If the standby power disappears, thus indicating the computer was unplugged, a power failure, etc. the computer must be off. If standby power reappears after disappearing, and the feature is enabled, the computer will automatically start booting as if the power button was pressed. So the feature may be more accurately described as "Motherboard automatically pushes its own power button if power completely disappears and then reappears".
So here's the scenario. Power goes out. UPS tells operating system to perform graceful shutdown. The UPS is still providing power from the battery, so the motherboard is still getting standby power. Thus, the feature will not boot the computer when power returns, because the computer doesn't realize power went out. However, if power isn't out long enough for the battery to drain, why did your computer shut down? You should only have the UPS shut down the computer if power really goes out. If it's one of those quick on/off situations the computer shouldn't shutdown at all. If it's not one of those situations, then the battery will drain, the computer will completely loser power, then it will reboot when power returns.
The problem there, which I just realized, is that if your UPS is completely empty, you don't want to boot your computer. You want to give the UPS a chance to recharge the battery without also putting a strain on that battery by turning on your computer. This is why wake on LAN is useful. Wake on LAN can turn your computer on while it is receiving standby power.
Lastly, if you have a quality UPS, it should be able to completely cut power to the computer after telling it to shut down. The computer will not receive standby power, the battery will not drain, and it will boot up when power returns.
I'm going to test this out this weekend in the following manner:
1) Set BIOS to boot on Power Fail.
2) Perform graceful shutdown.
3) Pull plug out of the wall after PC shuts down.
4) Wait a few minutes and plug power cord back into wall.
If the PC boots back up once I plug it in then everything is cool and I all I need to do is find a quality UPS that will cut power to the PC shortly after it sees it has shutdown.
All I know is that I have several PCs with this feature in the BIOS and they have never powered back up after a graceful shutdown followed by an interruption in AC power. Perhaps I just bought cheap shit and only the better ones have this capability. Or it could be that the hardware I used is so old that the technology did not operate in this manner until more recently.
1) Yank power while turned on = Reboot
2) Yank power while turned off = No Reboot
3) Yank power after putting PC in hibernation = Reboot
My server arrived and in the BIOS settings for this feature I found the following three options:
1) Disabled
2) Power On
3) Last (leave it in whatever state it was before you lost power)
Clearly not ALL current computers have the same level of support in the BIOS for this feature.