一个监控Squid运行进程数并自动重启的简洁Shell脚本分享
程序员文章站
2022-06-13 17:20:11
复制代码 代码如下:
#!/bin/sh
while sleep 30
do
squidnum=`ps -ef|grep squid|grep -v grep|wc...
复制代码 代码如下:
#!/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状态
if [ $squidnum != 3 ] ; then
/etc/rc3.duid start
adddate=`date +%y-%m-%d`" "`date +%h:%m:%s`
echo "$adddate squid started!" >> /home/resquid.log
fi
#超过5000个http请求就重启squid服务
httpnum=`netstat -an|grep 80|grep -v grep|wc -l`
if [ $httpnum -gt 5000 ] ; then
/etc/rc3.duid restart
adddate=`date +%y-%m-%d`" "`date +%h:%m:%s`
echo "$adddate http out 5000 squid started!" >> /home/resquid.log
fi
done