An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Previous Thread
Next Thread
Print Thread
WakeStick revisited
#23015 08/10/12 07:39 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
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
Re: WakeStick revisited
Virtual1 #23025 08/11/12 02:04 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
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
Re: WakeStick revisited
Kevin M. Dean #23026 08/11/12 02:11 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
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
Re: WakeStick revisited
Virtual1 #23027 08/11/12 04:50 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
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
Re: WakeStick revisited
Virtual1 #23028 08/11/12 05:13 PM
Joined: Aug 2009
Likes: 1
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 1
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
Re: WakeStick revisited
alternaut #23029 08/11/12 06:23 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
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
Re: WakeStick revisited
Virtual1 #23031 08/11/12 09:22 PM
Joined: Aug 2009
Likes: 1
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 1
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
Re: WakeStick revisited
alternaut #23032 08/11/12 10:28 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
this may be using the custom apc "powerchute" software. I haven't tried it myself recently.


I work for the Department of Redundancy Department

Moderated by  alternaut, cyn 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.4.33 Page Time: 0.022s Queries: 30 (0.016s) Memory: 0.6101 MB (Peak: 0.6953 MB) Data Comp: Zlib Server Time: 2024-03-28 11:27:28 UTC
Valid HTML 5 and Valid CSS