当前位置: > shell编程 >

监控Squid运行的简洁脚本

时间:2014-06-25 03:52来源:linux.it.net.cn 作者:IT网
#!/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

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容