Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!mauxci!eci386!woods From: woods@eci386.uucp (Greg A. Woods) Newsgroups: alt.sources.d Subject: Re: UPS monitor daemon part 1 of 1 Message-ID: <1991Apr11.155416.28426@eci386.uucp> Date: 11 Apr 91 15:54:16 GMT References: <1991Apr03.095011.9609@pilikia.pegasus.com> Reply-To: woods@eci386.UUCP (Greg A. Woods) Organization: Elegant Communications Inc. Lines: 45 [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@pilikia.pegasus.com> root@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@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