您的位置:首页 > 运维架构 > 反向代理

一个监控Squid运行进程数并自动重启的简洁Shell脚本分享

2014-12-23 09:42 931 查看

#!/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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息