centos 6上squid的相關腳本centos
一、sarg腳本bash
more /root/sarg.dailyide
cd /var/httpd/htdocsui
rm -rf `date '+%Y%b%d' -d '-60 day'`-`date '+%Y%b%d' -d '-60 day'`server
cp -f /SqLogs/access.log /root/access.logcrontab
/usr/local/bin/sarg -o /var/httpd/htdocs/ -l /root/access.logit
二、squid狀態檢查腳本class
more /root/squid_status.shawk
#crontab time 00:10sed
#!/bin/bash
#check Squid Status
#crontab time 00:10
SQUIDPORT=`netstat -na|grep "LISTEN"|grep "8888"|awk -F[:" "]+ '{print $5}'`
SQUIDPROCESS=`ps -ef | grep "(squid)" | awk '{print $8}' | sed 's/(\(.*\))/\1/'
| grep squid`
SQUIDIP=`ifconfig eth0|grep "inet addr" | awk -F[:" "]+ '{print $4}'`
SQUIDPID=`ps -C squid --no-header | wc -l`
DATA=`date +"%y-%m-%d %H:%M:%S"`
if [ $SQUIDPID -eq 0 ] || [ ! "$SQUIDPORT" == "3128" ] || [ ! "$SQUIDPROCESS"
== "squid" ];then
echo "$SQUIDIP squid service is DOWN!" | mail -s "warn!server: $SQUIDIP squid is
DOWN" lzy821218@51cto.com
/etc/init.d/squid start
if [ $? -eq 0 ] ;then
echo "$SQUIDIP squid service is UP!" | mail -s "OK!server: $SQUIDIP squid is UP"
lzy821218@51cto.com
fi
fi