[rc5] Monitoring clients

Joshua Weage weage at mtu.edu
Thu Jul 17 11:38:49 EDT 1997


> >> A little too crude for my tastes.  Better to have the script immediately
> >> restart the client if it dies.. rather than wasting valuable cycles with a
> >> cron job... :)
> >
> >#!/bin/sh
> >while true; do rc5v2; done
> 
> That's nice and all, but I was originally more concerned with restarting
> client when someone decideds to reboot the machines. (No, I'm not root on
> all of them)

	I missed the original message, but here is the script
that I use.  It runs as a cron job every 20 minutes and kills
the clients when someone logs onto console (required by my
sysad).  You could modify this to just start the clients
and not kill them.
	The quit_script section doesn't work yet since from
what I understand, the label used for the onintr command must
have already appeared in the script.



#!/bin/csh -f
# Joshua Weage's script to run programs in the background
# and terminate them when someone logs onto console.
# Run this script as a cron job every 10-20 minutes. 
# Comment out, or remove the echo statements when
# the script is working.

# Set the following variables appropritely
set progdir = '/home/cael/weage/bovine/'
set program = 'rc5.super'
set arguments = '-n 20 -a rc5proxy.distributed.net weage at mtu.edu'
set logdir = '/home/cael/weage/bovine/log/'
set ps = '/usr/bin/ps -e -o user,pid,args'
set username = 'weage'
set machine=`/usr/bin/hostname`

echo hostname set

# Make sure program isn't running already
set alive = `$ps | /bin/fgrep $username | /bin/fgrep -v grep | /bin/fgrep $program`
echo alive set 

if ("$alive" != "") then
	echo already running 
	exit
endif

# Check to make sure no one is currently logged on
set users = `/usr/bin/who | grep console`
echo users set

if ("$users" != "") then
	echo $users is on 
	exit
endif

# Ignore signals for the moment
onintr -

# Run the program
$progdir$program $arguments >>&! $logdir$machine.log &
echo program started

# Set process id's
set procs = `$ps | /bin/grep $username | /bin/grep -v grep | /bin/grep $program | /bin/awk '{print $2}'`
echo procs set 

# Quit on term signal
onintr quit_script

# Kill program when someone logs in
while(1)
	sleep 10
	set users = `/usr/bin/who | grep console`
	if ("$users" != "") then
		kill $procs
		echo killed 
		exit
	endif	
end

# Signal handler
quit_script:
kill $procs
exit


-- 
- Joshua Weage  weage at mtu.edu  http://www.me.mtu.edu/~weage    -
- "A well regulated militia, being necessary to the security   -
-  of a free state, the right of the people to keep and bear   -
-  arms, shall not be infringed."                              -
-           Second Amendment U.S. Constitution                 -
----
To unsubscribe, send email to majordomo at llamas.net with 'unsubscribe rc5' in the body.



More information about the rc5 mailing list