Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux教程 >> 監控Squid運行腳本

監控Squid運行腳本

日期:2017/2/7 14:39:09      編輯:Linux教程
 

#!/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.d/squid 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.d/squid restart
    adddate=`date +%Y-%m-%d`" "`date +%H:%M:%S`
    echo "$adddate http out 5000 squid started!" >> /home/resquid.log
fi
done

Copyright © Windows教程網 All Rights Reserved