复制代码 代码如下:
#!/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
您可能感兴趣的文章:
- shell脚本实现监控shell脚本的执行流程及变量的值
- Shell脚本实现Linux系统和进程资源监控
- Shell脚本实现监控MySQL主从同步
- Shell脚本实现监控iptables运行状态
- Shell脚本实现监控rsync数据是否传输完
- Shell脚本实现监控kingate并自动启动
- Shell脚本实现监控iptables规则是否被修改
- Shell脚本实现memcache缓存命中率监控
- Shell脚本编写Nagios插件监控程序资源占用
- Linux服务器硬件运行状态及故障邮件提醒的监控脚本分享
本文由 华域联盟 原创撰写:华域联盟 » 一个监控Squid运行进程数并自动重启的简洁Shell脚本分享
转载请保留出处和原文链接:https://www.cnhackhy.com/16499.htm