1984 has become truth! Thanks G. Orwell!

o eegauthe at cybaswan.UUCP
Sat Jun 17 02:39:48 AEST 1989


Hi there,

Once upon a time, I have had to help a "CPU time eater" to monitor its
processes: imagine a signal processing script which takes 15 mins for each
file and...  repeated on more than 200! It was a hell because, at first, they
started several processes in parallel and...  I didn't know whether ed didn't
acknowledge any keystroke at once because the system was crashed, or because
the tty handler didn't have any more CPU time! And I had to write a report!
Sorry I forgot to mention 1 detail: we had to reboot the system every night,
so the script was stopped then! When I saw their poor faces I decided to help
them.  Here is the result:

bb (short for "Big Brother" -> what a culture!) is a process monitor script:
it checks whether the pid given as an argument is still allocated; in this
case bb updates a status file in your login directory (bb<pid>): it contains
all the processes currently associated with the pid's tty: this means that you
can monitor any process on any tty and don't get too much rubbish in the
status file! If the process has died, bb will report it onto the terminal, and
leave a message in the status file.  If a long list of processes is run in a
script, and, for some reason, the script is killed, the status file will
indicate at which stage to restart the script, so you don't have to restart
everything again.  Now a quick description of the beast:

	* invocation: bb <process number> [-k]
		the -k option will clear the login shell when "pid" is
		finished (handy if you run a long process, and you want an 
		"auto-logout" at the end).  The only limitation for this
		option is that you must be owner of the process. 

		Note: this should be sent in the background, or there is not
		much point in running it!

	-> acknowledge: "Big Brother is watching process # on tty @"
		"#" stands for the pid and "@", the tty name

	-> when "pid" is finished: "process # is finished"

Hope that helps!

	Olivier.

-----------------------------------8<-----------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  bb
# Wrapped by eegauthe at cybaswan on Fri Jun 16 17:35:23 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'bb' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bb'\"
else
echo shar: Extracting \"'bb'\" \(787 characters\)
sed "s/^X//" >'bb' <<'END_OF_FILE'
X:	/bin/sh
X:
X:	Big_Brother: a spy on the system
X:	Version 2.0	(28/5/89)
X:	Author		Olivier Gautherot
X:
X:
X:	test number of arguments
X:
Xif ( test $# = 0 )	then
X	echo "Usage: $0 <pid> [-k]"
X	echo "A message will be sent to the screen on completion of the process"
X	echo "and a temporary file will be left in the login directory"
X	exit 1
Xfi
X:
X:	get tty number
X:
Xtty=`ps -p$1 | grep $1 | awk '{print $2}'`
X:
Xecho ""
Xecho Big Brother is watching process $1 on tty $tty
X:
X:	monitor the process
X:
Xwhile ps -p$1 > /dev/null
Xdo
X	(date ;\
X	echo "" ;\
X	ps -gut$tty ) > $HOME/b$1
X	cp $HOME/b$1 $HOME/bb$1
X	rm $HOME/b$1
X	sleep 15
Xdone
X:
X:	process has exited
X:
Xecho Process $1 finished
Xcase $2 in
X	"-k")	kill -9 `ps -ct$tty | grep tcsh | awk '{print $1}'`
X	echo Login shell killed;;
Xesac
X:
X:	End of file
END_OF_FILE
if test 787 -ne `wc -c <'bb'`; then
    echo shar: \"'bb'\" unpacked with wrong size!
fi
chmod +x 'bb'
# end of 'bb'
fi
echo shar: End of shell archive.
exit 0
-----------------------------------8<-----------------------------------
-- 
Olivier GAUTHEROT,// Postgraduate // Electrical Engineering Dept.
University of Wales // Swansea, SA2 8PP, U.K.	(+44 792 205678 ext 4564)
UUCP  : ...!ukc!pyr.swan.ac.uk!eegauthe    JANET : eegauthe at uk.ac.swan.pyr
	"A lovely girl in a hammock is a hanging garden."	A. Allais



More information about the Alt.sources mailing list