#!/bin/csh # $Id: nanny,v 1.3 2003/08/22 02:53:06 vivek Exp $ # This is the nanny process for the proxy. It periodically checks if # the proxy is alive. Every time the proxy responds, a counter is # reset, and every time the proxy doesn't respond, the counter is # incremented. If the counter reaches the specified value, the system # is rebooted. # The value 'maxFailedCount' is the number of successive failures # needed before rebooting the system. The value 'sleepTime' indicates # how long to sleep between probing the proxy. The value 'beginningSleepTime' # indicates the amount of time to sleep before starting the nanny. set maxFailedCount=4 set sleepTime=30 set beginningSleepTime=600 set isRunning=0 set failedCount=0 set defPath = ~ # default Path set proxPath = ${defPath}/CoDeeN/usr/local/prox set mlist = (`cat ${proxPath}/admin_list`) # admin list setenv PATH ${proxPath}:${defPath}/CoDeeN/usr/local/bin:/usr/bin:/bin:/sbin:${PATH} sleep $beginningSleepTime while (1) @ isRunning= `${defPath}/codeen_uptime |& grep -c Timeticks` if $isRunning then @ failedCount= 0 else @ failedCount= $failedCount + 1 endif if ($failedCount >= $maxFailedCount) then # notify the admins of restarting the servers foreach person ($mlist) mail -s"Proxy servers restarting" $person << ! NOTE: Proxy servers at `hostname` are being restarted at `date`. ! end # restart the proxy cd $defPath ./prox_restart sleep $beginningSleepTime endif sleep $sleepTime end