[NTLUG:Discuss] Service Watchdog Script
joseph beasley
joe_beasley at yahoo.com
Tue Oct 6 19:20:03 CDT 2009
Here's what I use for snort and barnyard.
checksnort.sh
#!/bin/sh
## init vars
running=0
counter=0
## Test for Running Process
IS_Alive()
{
kill -0 `cat /var/run/snort.2.8.0.1/snort_eth1.pid`
if [ $? -eq 0 ]
then running=1
else
running=0
fi
}
Start_IT()
{
/etc/init.d/snort start
counter=`expr $counter + 1`
if [ $counter -eq 5 ]
then echo "Snort is not running on machinename" | /usr/bin/nail -s "SNORT CHECK" someaddress at somewhere.com
fi
if [ $counter -eq 1 ]
then echo "Starting Snort on machinename" | /usr/bin/nail -s "Starting Snort on machinename" someaddress at somewhere.com
fi
}
IS_Alive
while [ $running -eq 0 ]
do
Start_IT
sleep 60
IS_Alive
done
Kicking high blood pressure in the ass with sparkpeople.com.
________________________________
From: CoryC <oakleeman at yahoo.com>
To: discuss at ntlug.org
Sent: Mon, October 5, 2009 12:03:30 PM
Subject: [NTLUG:Discuss] Service Watchdog Script
Does anybody have an example of a service watchdog script that they are willing to share? All of the examples I'm finding on the Internet only work if the service uses a port but not all of the services I want to monitor use a port (Snort, arpwatch, etc.). I'd like for it to be able to e-mail me when one of those services are down and possibly even try to restart it. I'm using CentOS 5.3.
Thanks,
Cory
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss
More information about the Discuss
mailing list