每10分钟统计访问量

######################按每10分钟统计指定url访问次数##########################
# $1 url
# $2 dd/MM/yyyy:HH
#!/bin/sh
if [ "$1" = "" ]
then
url="/images/newshyh/shkx.png"
echo "*******url is default value:"$url
fi
if [ "$2" = "" ]
then
DATE=`date|awk '{print $3"/"$2"/"$6":"$4}'|cut -c -14`
fileDate=`date +%Y_%m_%d`
echo "*******Date is default value:"$DATE
fi
if [ "$1" != "" ]
then
url="$1"
fi
if [ "$2" != "" ]
then
DATE="$2"
fi
year=`echo $DATE|cut -c 8-11`
Emonth=`echo $DATE|cut -c 4-6`
day=`echo $DATE|cut -c -2`
if [ "$Emonth" = "Jan" ]
then
month="01"
elif [ "$Emonth" = "Feb" ]
then
month="02"
elif [ "$Emonth" = "Mar" ]
then
month="03"
elif [ "$Emonth" = "Apr" ]
then
month="04"
elif [ "$Emonth" = "May" ]
then
month="05"
elif [ "$Emonth" = "Jun" ]
then
month="06"
elif [ "$Emonth" = "Jul" ]
then
month="07"
elif [ "$Emonth" = "Aug" ]
then
month="08"
elif [ "$Emonth" = "Sep" ]
then
month="09"
elif [ "$Emonth" = "Oct" ]
then
month="10"
elif [ "$Emonth" = "Nov" ]
then
month="11"
elif [ "$Emonth" = "Dec" ]
then
month="12"
fi
fileDate=$year"_"$month"_"$day
echo "==============================10minute stat info start======================================="
M="`seq -w 0 5`"
LOG='/porweb/apache2.2/logs'
LOG1='/porweb1/apache2.2/logs'
files="`ls -trl ${LOG}/*$fileDate.log ${LOG1}/*$fileDate.log | awk '{print $9}'`"
echo " 统计时间 时间段 访问量"
for a in ${M}
do
num=`cat ${files} |awk '{print}' |grep "${url}"|grep "${DATE}:${a}"|wc -l`
echo "${DATE} ${a}0-${a}9 ${num}"
echo "------------------------------"
done
echo "===============================10minute stat info end========================================="

相关文档
最新文档