An open community 
of Macintosh users,
for Macintosh users.

FineTunedMac Dashboard widget now available! Download Here

Previous Thread
Next Thread
Print Thread
UPS defeating its purpose
#10386 06/05/10 01:37 AM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
I have a backup/remote server here on a UPS. It lost power 20 minutes after I left for work this morning. The UPS probably held it for about 25 minutes and then signaled the energysaver to shut down, which it did.

The MP did not however, turn back on again when power was restored, and was off until I got home and realized it was off. I did have "restart after power failure" checked.

As far as I can tell, if I hadn't had the UPS or set it to shut down when runtime gets low, and it had just abruptly shut down, it would have properly started back up when power came back.

So, in short, the UPS COST me uptime today, to the tune of almost 10 hours. How to fix this?

I suppose I need to either find a way to do an orderly shutdown that sets the "restart when power comes back" flag wherever, or I need to find a way to tell the nvram to do a timed wakeup at something like five minute intervals starting in 20 minutes, or is there something else I can do?

Don't want to hear about hardware solutions. I know I can baytech it or something like that but I'm insulted to have to throw more money at this problem beyond the good UPS I've already bought. The hardware I've already bought should be solving the problem, not making it worse.


I work for the Department of Redundancy Department
Re: UPS defeating its purpose
Virtual1 #10404 06/05/10 01:16 PM
Joined: Aug 2009
Likes: 2
Moderator
Offline
Moderator

Joined: Aug 2009
Likes: 2
Are you sure you want the MP to restart as soon as power is restored? Have you ever noticed how often power restoration is on and off, sometimes several times, before it finally stabilizes? Commercial and military backup systems whether they are battery, generator, or a combination of both impose a 3 to 5 minute delay before switching back to line power to be sure the restored power is stable.

In your case you have already exhausted the UPS battery to a very low level so it may or may not provide any support during the period of instability as line power is restored. Therefore your immediate boot could be interrupted by a subsequent loss of power and I am ignoring the probability of huge spikes that might get past the filters in the UPS.


joemikeb • moderator
Re: UPS defeating its purpose
joemikeb #10405 06/05/10 02:58 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
Problem solved, with help from a friend. Successfully bounced ideas off each other and came up with this:

Code:
#!/bin/bash

################################################################################
#
#  Script to be cronned every five minutes or so by a computer on a UPS that
#  needs to power on asap after power is restored after the UPS has ran out
#  of power and the computer has shut down
#
################################################################################

delay=30

# initial delay (in minutes)  before trying to start computer.  you want this to
# be longer than you know your UPS can run with the computer off because you
# don't want it to try to start the computer up right as the UPS is about to die

interval=60

# interval (in minutes) between events.  the lower the interval, the sooner it
# will turn on after power is restored.

ecount=12

# number of events.  the more events, the longer this script will take to run,
# but the longer the period of time it will continue to try to power back on.
# pmset appears to have  no limit to the number of scheduled events.

################################################################################

# delete all existing scheduled events.  takes 1/2 sec or so per event.  there is no "clear all" command.
pmset -g sched | grep "poweron" | while read n ; do pmset schedule cancel poweron "${n#* at }" ; done

# set power-on events
for ((e=0;e<ecount;e++)) ; do
  pmset schedule poweron "$(date -j -f "%s" $(($(date "+%s")+60*delay+60*interval*e)) "+%m/%d/%y %H:%M:%S"))"
done

pmset -g sched > /var/root/wakestick_updated


The idea is it is cronned every 5 minutes and updates the scheduled power on times, so no need to do anything when we drop over to ups power. So I have my ups set to orderly shutdown at 10 min power left. And I have the delay set to 30, so it will try to turn itself back on again 20 minutes after it shuts off. Ideally I want the UPS to have ran out of battery at that point, so there's no risk of it trying to power on when the ups has very little power left. (and lose power during startup)

If power isn't back yet, it will try again in an hour, and another from then for up to half a day. That should be enough.

Requires 10.5 or later due to the -j flag in the date command.


I work for the Department of Redundancy Department
Re: UPS defeating its purpose
joemikeb #10406 06/05/10 03:14 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
In your case you have already exhausted the UPS battery to a very low level so it may or may not provide any support during the period of instability as line power is restored. Therefore your immediate boot could be interrupted by a subsequent loss of power and I am ignoring the probability of huge spikes that might get past the filters in the UPS.

You'd have to see my setup to understand. There's a very large isolation transformer between the UPS and the power bar. (basketball size, weighs about 70 lbs) It means business, and isolates from ground, completely. As such it's got a massive iron core that saturates nicely, so it's immune to even the largest of spikes and helps with line noise. The addition of a 4" iron core choke and three stage filter choke finishes it. The way the setup is, my cats could come chew on the power wires (one at a time I suppose) and not get shocked, and I've had lightning hit here numerous times with no problems.

and this:
pmset -g ps | head -n 1 | cut -d "'" -f 2
will either tell you "AC Power" or "UPS Power", making it trivially easy to get cron to drop me an email when it falls over to UPS power.


I work for the Department of Redundancy Department
Re: UPS defeating its purpose
Virtual1 #10408 06/05/10 05:16 PM
Joined: Aug 2009
Offline

Joined: Aug 2009
You might find this MacInTouch Reader report of interest (especially the comments from Tomaso Forchiassin):

Battery Backup: Questions


MicroMat Inc
Makers of TechTool
Re: UPS defeating its purpose
MicroMatTech3 #10409 06/05/10 09:16 PM
Joined: Aug 2009
OP Offline

Joined: Aug 2009
Some good information in there tho the engrish in the first post about made my eyeballs jam. They appeared to be addressing more of the sleep/wake issues of UPSs.

I've finished the setup here and now will receive emails when systems here go on or off battery power, and have the poweron set properly on the backup server that was having the ups downtime issues. At least then I can remote in and take a peek, assuming the ISPs are still functional. (MY gear is, theirs up on the poles, hard to say!)



I work for the Department of Redundancy Department
Re: UPS defeating its purpose
Virtual1 #10411 06/05/10 09:43 PM
Joined: Aug 2009
Moderator
Offline
Moderator

Joined: Aug 2009
[Off-topic]

Originally Posted By: Virtual1
...the engrish in the first post about made my eyeballs jam.

The reason Tomaso occasionally sounds like a non-native English speaker is that he's Italian. But he did a much better job telling his story in Engrish than I ever could in Italian. Bravo!

[/Off-topic]


alternaut moderator

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.3.24 Page Time: 0.015s Queries: 28 (0.008s) Memory: 0.7367 MB (Peak: 0.8153 MB) Data Comp: Zlib Server Time: 2020-11-29 09:55:56 UTC
Valid HTML 5 and Valid CSS