[comp.sys.misc] Auto shutdown

alan@curly.Viewlogic.COM (Alan Medsker) (09/08/90)

I've got an Epoch-1 Infinitestorage NFS server, and a UPS that it runs
off of.  I'd like to find a way to have the server shut down
gracefully unattended when the power has been down for x minutes.

I need an external box of some sort, no doubt, either driven by the
contacts on the UPS (Clary) or just by the presence of power at an
outlet.

I'm thinking of a box that sends a programmable set of character
strings to an RS-232 port when the power goes down, and one or 
two settable periods after the power goes down, and when the power 
is restored.

Any ideas?

Alan

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alan Medsker                                 Viewlogic Systems, Inc.
Voice: (508) 480-0881                        293 Boston Post Road West
Fax: (508) 480-0882                          Marlboro, MA  01752
Internet: amedsker@Viewlogic.COM
cc:Mail: Alan Medsker at Viewlogic
CI$: 76376,662
BIX: amedsker
2 Meters: WB0SQR
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
My opinions, of course.  And don't hold me to them.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

davecb@yunexus.YorkU.CA (David Collier-Brown) (09/09/90)

alan@curly.Viewlogic.COM (Alan Medsker) writes:
>I've got an Epoch-1 Infinitestorage NFS server, and a UPS that it runs
>off of.  I'd like to find a way to have the server shut down
>gracefully unattended when the power has been down for x minutes.

An almost pure-software approach is the following --
	wire a ups-delivering-power signal to dtr on a serial port
	take the getty off that port
	write a program to watch the port and implement your
	shutdown policies based on the period the line has been asserted.
--dave
-- 
David Collier-Brown,  | davecb@Nexus.YorkU.CA, ...!yunexus!davecb or
72 Abitibi Ave.,      | {toronto area...}lethe!dave or just
Willowdale, Ontario,  | postmaster@{nexus.}yorku.ca
CANADA. 416-223-8968  | work phone (416) 736-5257 x 22075

bernie@DIALix.oz.au (Bernd Felsche) (09/09/90)

In article <1990Sep7.174211@curly.Viewlogic.COM> alan@curly.Viewlogic.COM (Alan Medsker) writes:
>I've got an Epoch-1 Infinitestorage NFS server, and a UPS that it runs
>off of.  I'd like to find a way to have the server shut down
>gracefully unattended when the power has been down for x minutes.
>
>I need an external box of some sort, no doubt, either driven by the
>contacts on the UPS (Clary) or just by the presence of power at an
>outlet.
>
>I'm thinking of a box that sends a programmable set of character
>strings to an RS-232 port when the power goes down, and one or 
>two settable periods after the power goes down, and when the power 
>is restored.
>
>Any ideas?
>
Yup: Use the computer.

If the UPS has a normally closed (mains available contact) then all
you need to do is to hook up a serial cable to spare port on your
computer.  You can check the mains directly, by getting a relay
which has a mains-rated coil, and connecting that to a power point.
I think that you can find a cheap plug-pack-type enclosure to stuff
this into, making a tidy installation.

The contacts merely connect the RX and TX lines, so that when the
computer send a character, it will be echo'd back, if mains is
available. Net hardware cost <$10!  Some implementations may use
DCD instead, but modem support is not always available.

Now that I've told you, it's obvious, isn't it?

Some software on the machine periodically spits out a byte and
listens for it.  Software could also time the power outage and
estimate how serious the problem is.  Another nicety would be to
abort shutdown if power returns and has stabilised.

You can prototype the software as a script, which is usually 
good enough as you'd only have to check once a minute, don't you?

bernie

@tree.uucp (Chris Gonnerman) (09/13/90)

In article <562@DIALix.UUCP>, bernie@DIALix.oz.au (Bernd Felsche) writes:
> In article <1990Sep7.174211@curly.Viewlogic.COM> alan@curly.Viewlogic.COM (Alan Medsker) writes:
> >I've got an Epoch-1 Infinitestorage NFS server, and a UPS that it runs
> >off of.  I'd like to find a way to have the server shut down
> >gracefully unattended when the power has been down for x minutes.
> >Any ideas?
> >
> Yup: Use the computer.
> 
> If the UPS has a normally closed (mains available contact) then all
> you need to do is to hook up a serial cable to spare port on your
> computer.  You can check the mains directly, by getting a relay
> which has a mains-rated coil, and connecting that to a power point.
> I think that you can find a cheap plug-pack-type enclosure to stuff
> this into, making a tidy installation.
> 
> bernie


We did the same thing with a "network-compatible" UPS that turned out to
have only a normally-open contact, which closes (connects) on power
outage.  My code was simpler, though: it opens the port and runs
shutdown.

My cables run the UPS connections to the DCD and DTR lines.  When open()
is attempted on a port, DTR is asserted and DCD is waited for.  When
open() returns, therefore, DCD has been detected.

When the power fails, the computer's DTR line is connected to it's DCD
line, and open() is allowed to return.

So, the program sleeps constantly until power fails, then the kernel
wakes it and the system is brought down gracefully.

Simple, huh?  Most systems with healthy serial drivers and hardware can
do the same thing.

-- 
 +----------------------------------------------------------------------------+
 | Chris Gonnerman (Mad Programmer At Large)   csusac.ecs.csus.edu!tree!jcg   |
 | @ the Tree BBS, Sacramento, CA              ucbvax!ucdavis!csusac!tree!jcg |
 +----------  DISCLAIMER: These opinions are mine... MINE, I say!  -----------+