UPS monitor daemon part 1 of 1

Greg A. Woods woods at eci386.uucp
Fri Apr 12 01:54:16 AEST 1991


[BTW, just as a reminder for people who post sources to alt.sources:
Please set the "Followup-To:" header to alt.sources.d.]

In article <1991Apr03.095011.9609 at pilikia.pegasus.com> root at pilikia.pegasus.com (Art Neilson) writes:
> 	The UPS monitor daemon or "upsd"  watches the serial port
> 	connected to an UPS and will perform an unattended shutdown
> 	of the system if the UPS is on battery longer than a specified
> 	number of minutes.

Neat-oh.  How about a feature that can calculate the total time down
and the average charging time, and thus be able to figure out how long
the battery will last?  I've seen this in a couple of commercial pgms.

>[....]
> echo shar: Extracting \"'README'\" \(3910 characters\)
> sed "s/^X//" >'README' <<'END_OF_FILE'
> X	Tue Apr 02 23:24:20 HST 1991	art at pilikia.pegasus.com		Pg. 1
>[....]
> X	usage: upsd [-d tty][-c cmd][-l log][-t min]
> X		-d tty		pathname of UPS device
> X		-c cmd		pathname of shutdown command
> X		-l log		pathname of UPS log file
> X		-t min		delay time in minutes
.[....]
> X	The -c cmd option specifies the full pathname of the command
> X	to be executed to shut down the system.  This command must
> X	be enclosed in quotes if it consists of 2 or more words.

A more elegant solution for System V is to just sent a SIGPWR to init,
i.e. kill(1, SIGPWR); and have your inittab configured correctly to
"do the right thing" with powerfail (and/or powerwait) entries.  Why
waste all that code which was put there for just this feature?

/etc/shutdown scripts are for human users, and can vary widely -- some
even ask for confirmation!  Not something the average daemon can answer!

Init is also smart about what it does with powerfail and powerwait
depending upon the current run-level, thus even if you are in
single-user mode, it can, for example, be configured to run 'sync'
and/or uadmin to halt the kernel.
-- 
							Greg A. Woods
woods@{eci386,gate,robohack,ontmoh,tmsoft}.UUCP		ECI and UniForum Canada
+1-416-443-1734 [h]  +1-416-595-5425 [w]  VE3TCP	Toronto, Ontario CANADA
Political speech and writing are largely the defense of the indefensible-ORWELL




More information about the Alt.sources.d mailing list