centos 6上squid的相关脚本


1、sarg脚本

more /root/sarg.daily

cd /var/httpd/htdocs

rm -rf `date  '+%Y%b%d' -d '-60 day'`-`date  '+%Y%b%d' -d '-60 day'`

cp -f /SqLogs/access.log /root/access.log

/usr/local/bin/sarg -o /var/httpd/htdocs/ -l /root/access.log


2、squid状态检查脚本


more /root/squid_status.sh

#crontab time 00:10

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