#!/bin/sh
while sleep 30
do
SquidNum=`ps -ef|grep squid|grep -v grep|wc -l`
#HttpNum=`netstat -an|grep 0.0.0.0:80|grep -v grep |wc -l` #80 Status
if [ $SquidNum != 3 ] ; then
/etc/ start
adddate=`date +%Y-%m-%d`" "`date +%H:%M:%S`
echo "$adddate squid started!" >> /home/
fi
#Restart the squid service after more than 5000 http requests
HttpNum=`netstat -an|grep 80|grep -v grep|wc -l`
if [ $HttpNum -gt 5000 ] ; then
/etc/ restart
adddate=`date +%Y-%m-%d`" "`date +%H:%M:%S`
echo "$adddate http out 5000 squid started!" >> /home/
fi
done