An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Topic Options
#23015 - 08/10/12 12:39 PM WakeStick revisited
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
I think this is an old topic I'm revisiting but just wanted to see if anyone else has ran into anything new on this subject.

The problem: commercial power loss for unattended servers. Attach a UPS. OK that's good. Set energysaver to shut down computer when 10% of ups power remains etc. Also good. Power out for an hour. Comes back. Good. Server remains turned off until someone gets back onsite to press the power button. not good.

Other option: do not set server to shut off on low ups power. not good. set energysaver to restart after power loss. ok. power goes out for an hour. computer experiences hard power loss, possible hardware damage, and possible disk corruption. not good. power comes back on. server restarts and hopefully is ok and can fix any directory issues that were created.

so... we have a lose/lose situation here really. We can either take the safe approach and have to make a road trip to press a power button. (or phonecall to someone with the right key etc) OR we risk directory corruption or possible hardware damage.


To mitigate this, I have created a script WakeStick that crons every minute and checks pmset's indicators for UPS status. When "on battery power" appears, a message is emailed. When power is restored, another email is sent. Every 10 minutes another email is sent with an update on estimated UPS time. Energysaver is relied on to shut down the computer when UPS power gets low or runtime has reached the limit.

However, every time WakeStick is cronned, it builds a new set of "power on" alarms into pram. They are configurable, but generally speaking they're set to power on 30 minutes from current time, plus every 15 minutes thereafter for a few more hours, and then two more an additional 6 and 12 hours later. When the server comes back up again, another email notice is sent.

This gets the machine to soft power off before total power loss, and gets it back on again as fast as is reasonably possible.


Is there another good solution to this issue? I'm amazed that I don't find anything built into the Mac OS that will handle this common scenario reasonably well.



(I am also planning a few upgrades to wakestick here, one already in place uses an external smaller ups to provide power notices in the case where a large ups cannot talk to the mac, the other I have not yet implemented will ping another device on the lan that is NOT on a ups and use it in the same way as the little ups - in those cases wakestick does the power-down after a preset amount of time on battery power since it can't tell how much battery remains)
_________________________
I work for the Department of Redundancy Department

Top
#23025 - 08/11/12 07:04 AM Re: WakeStick revisited [Re: Virtual1]
Kevin M. Dean Offline


Registered: 08/04/09
Loc: Florida
This link implies that some UPS tabs in Energy Saver has a Restart after Power Failure option as well (mine doesn't), which supposedly will restart when the UPS receives power again. It may just mean having the right feature on the UPS.

Apple Discussion
_________________________
iMac 2.7 GHz Core i5, 12 GB RAM, OS X 10.9, Int SATA 1 TB, Ext Fire 2 TB / 1 TB / 1 TB / 500 GB / 300 GB
Former MacFixIt Forums member since 11/17/99
www.rhubarbproductions.com

Top
#23026 - 08/11/12 07:11 AM Re: WakeStick revisited [Re: Kevin M. Dean]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
that discussion reads a little confused, but the option they refer to is "restart after power failure". While that sounds like it might turn back on again after a ups shutdown, the reality is that it only restarts if you have an UNclean shutdown from a total power loss.

So if you don't configure it to shut down the computer at a battery percent or runtime on battery, it WILL shut down uncleanly when the UPS gives out, and the it WILL restart.

But if you have the settings configured to shut down the computer gracefully when on battery for so long or after battery power gets so low, it will NOT restart when power is restored.

And that is the problem. You have to pick between the lesser of two evils: not restarting automatically after a clean shutdown due to low ups, or suffering an unclean shutdown.
_________________________
I work for the Department of Redundancy Department

Top
#23027 - 08/11/12 09:50 AM Re: WakeStick revisited [Re: Virtual1]
Kevin M. Dean Offline


Registered: 08/04/09
Loc: Florida
I read it as having separate restart options on both the Power tab and the UPS tab. I don't have it on the UPS tab, but maybe you do. Alternatively, I'd check with the software for your UPS because they usually have more options there. Although if you run the APC brand, you may need to run the software on Windows because the Mac software doesn't show all of the options.
_________________________
iMac 2.7 GHz Core i5, 12 GB RAM, OS X 10.9, Int SATA 1 TB, Ext Fire 2 TB / 1 TB / 1 TB / 500 GB / 300 GB
Former MacFixIt Forums member since 11/17/99
www.rhubarbproductions.com

Top
#23028 - 08/11/12 10:13 AM Re: WakeStick revisited [Re: Virtual1]
alternaut Offline

Moderator

Registered: 08/04/09
Bob_M. claims that auto-reboot on power failure is possible with APC UPSs in the Apple Discussions thread Restart after Power Failure using Belkin UPS? He lists the successive steps of the process in his 4th post there. Is he right or wrong?
_________________________
alternaut moderator

Top
#23029 - 08/11/12 11:23 AM Re: WakeStick revisited [Re: alternaut]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
steps 4 through 6 are a good solution to the problem, but I don't see how they are being accomplished, unless they are using some special ups drivers (belkin?)

it looks like it does the normally timed "shut down when battery power is at15% of capacity" etc, but instead of fully shutting down, it shuts down all the way short of killing power. so by that point the shutdown is clean. then it sits there hung until power DOES run out. then the SMC records the power loss shutdown cause, and when power is restored, it can turn the computer back on.

If that's all there is to it, there's a race condition there, can you spot it?

What happens if the computer goes into its safe shutdown hang, and then the power is restored, before the UPS loses battery and shuts off? Then the computer sits there, back on line power, hung, until you come back and kill it.

I'm familiar with race conditions there. I had the insanely bad luck to have a machine lose ups power DURING the reprogramming of the timed restarts in wakestick. (it was in the process of removing the old events before entering the new ones, set five minutes later) Now wakestick records the old entries, adds the new entries, THEN removes the old ones.

The BEST solution to this problem is a little tweak to the SMC and to the Mac OS X. It should have another checkbox in energysaver, "restart after UPS power has been restored for [ ] minutes." That would set a pram flag, and then it could shut down the computer on low ups as normal. Then when UPS power was restored, the pmu should check both the power loss AND the restart flags, and turn on if and when necessary. Then have OS X only unset that flag when it gets back up enough to clear the SMC dirty shutdown flag.

Note that the same race condition exists there too. An additional timer may be necessary, to tell the computer to start back up again after [ ] minutes off if power is never lost. Maybe this additional complexity is the reason it hasn't been implemented by apple yet/
_________________________
I work for the Department of Redundancy Department

Top
#23031 - 08/11/12 02:22 PM Re: WakeStick revisited [Re: Virtual1]
alternaut Offline

Moderator

Registered: 08/04/09
Originally Posted By: Virtual1
... steps 4 through 6 are a good solution to the problem, but I don't see how they are being accomplished, unless they are using some special ups drivers (belkin?)

As I'm not sure your take on this AD post is the same, I'll reiterate mine here: Bob_M claims that APC UPSs can successfully reboot a connected computer after a power failure, while Belkin UPSs cannot. I draw this conclusion based on the section stating:

The process is this:
1. [details removed] >> 10.
The system works as advertised for APC UPSs.


Am I reading too much in this? If not, I assumed that this is what you're looking for.
_________________________
alternaut moderator

Top
#23032 - 08/11/12 03:28 PM Re: WakeStick revisited [Re: alternaut]
Virtual1 Offline


Registered: 08/04/09
Loc: Iowa
this may be using the custom apc "powerchute" software. I haven't tried it myself recently.
_________________________
I work for the Department of Redundancy Department

Top

Moderator:  alternaut, cyn