#!/bin/csh -f # # check web page for service # # written by Kevin P. Inscoe (kevin@inscoe.org) (12/04/2002) # # check_http is a plugin for the Nagios monitoring system and can # be downloaded from http://www.nagios.org # # global variables # setenv LD_LIBRARY_PATH /usr/local/lib:/usr/local/ssl/lib:/usr/lib set URL = "/test/upcheck.html" set SITE = "foobar.org" set DTMP = `/bin/date '+%H%M%S'` setenv TMP /tmp/check_proc_$DTMP.tmp #set BROWSER_CMD = "/opt/LYNX271/bin/lynx -dump -error_file=$TMP" set BROWSER_CMD = "/usr/local/nagios/libexec/check_http -H $SITE -u $URL -t 40" set RCPT = "joeschmoo@somewhere.com,somebodyelse@somewhere.com" set EXPECTED = "HTTP/1.1 200 OK" @ SLEEP_INTERVAL = 1 * 60 # last hour/min of the day (24 hour) to run set lastrun = 2345 @ lastsum = 0 # # Announce ourselves # /bin/echo $0 "starting at `/usr/bin/date`" top: # # Cleanup file # if ( -e $TMP ) /bin/rm -f $TMP /bin/touch $TMP # # check URL and make sure it responds # echo "******" echo "Connection statistics at `/bin/date`..." /usr/ucb/echo -n "ESTABLISHED: " netstat -an | grep "10.0.0.25.80" | grep ESTABLISHED | wc -l /usr/ucb/echo -n "SYN_RCVD: " netstat -an | grep "10.0.0.25.80" | grep SYN_RCVD | wc -l /usr/ucb/echo -n "SYN_SEND: " netstat -an | grep "10.0.0.25.80" | grep SYN_SEND | wc -l /usr/ucb/echo -n "CLOSE_WAIT: " netstat -an | grep "10.0.0.25.80" | grep CLOSE_WAIT | wc -l /usr/ucb/echo -n "TIME_WAIT: " netstat -an | grep "10.0.0.25.80" | grep TIME_WAIT | wc -l /usr/ucb/echo -n "LAST_ACK: " netstat -an | grep "10.0.0.25.80" | grep LAST_ACK | wc -l /usr/ucb/echo -n "FIN_WAIT_2: " netstat -an | grep "10.0.0.25.80" | grep FIN_WAIT_2 | wc -l /usr/ucb/echo -n "FIN_WAIT_1: " netstat -an | grep "10.0.0.25.80" | grep FIN_WAIT_1 | wc -l # king connections /usr/ucb/echo -n "king ESTABLISHED: " netstat -an | grep "10.0.0.3" | grep ESTABLISHED | wc -l /usr/ucb/echo -n "king SYN_RCVD: " netstat -an | grep "10.0.0.3" | grep SYN_RCVD | wc -l /usr/ucb/echo -n "king SYN_SEND: " netstat -an | grep "10.0.0.3" | grep SYN_SEND | wc -l /usr/ucb/echo -n "king CLOSE_WAIT: " netstat -an | grep "10.0.0.3" | grep CLOSE_WAIT | wc -l /usr/ucb/echo -n "king TIME_WAIT: " netstat -an | grep "10.0.0.3" | grep TIME_WAIT | wc -l /usr/ucb/echo -n "king LAST_ACK: " netstat -an | grep "10.0.0.3" | grep LAST_ACK | wc -l /usr/ucb/echo -n "king FIN_WAIT_2: " netstat -an | grep "10.0.0.3" | grep FIN_WAIT_2 | wc -l /usr/ucb/echo -n "king FIN_WAIT_1: " netstat -an | grep "10.0.0.3" | grep FIN_WAIT_1 | wc -l echo "Checking $URL at `/bin/date`..." $BROWSER_CMD $URL > $TMP /bin/cat $TMP /bin/grep "$EXPECTED" $TMP > /dev/null if ( $status == 0 ) goto sleep echo "some-web is not running... stopping at `/bin/date`..." sh -c "/opt/NSCP/server/enterprise/4.1sp9/https-some-web/stop" # it doesn't stop netscape. Do it again sleep 2 sh -c "/opt/NSCP/server/enterprise/4.1sp9/https-some-web/stop" echo " ... sleeping 5 seconds at `/bin/date`" sleep 5 # ------ echo " ... starting at `/bin/date`" # start 2 times. It doesn't startup all the time until the loop # hits again # sh -c "/opt/NSCP/server/enterprise/4.1sp9/https-some-web/start" sleep 2 sh -c "/opt/NSCP/server/enterprise/4.1sp9/https-some-web/start" # #echo "some-web restarted at `/bin/date`" | mailx -s "`echo $SITE` restarted" $RCPT echo "some-web restarted at `/bin/date`" sleep: # Check to see if we are still in our window... set hour = `/usr/bin/date '+%H%M'` if ( $hour < $lastrun ) then echo "sleeping at `/bin/date`..." sleep $SLEEP_INTERVAL goto top endif # # our tour of duty is over..time to bail # /bin/echo "lastrun completed...exiting at `/usr/bin/date`" exit 0