全部博文(535)
分类: LINUX
2014-06-08 09:43:15
####################按小时统计url访问次数
# $1 url
#!/bin/sh
if [ "$1" = "" ]
then
echo "Url is null ... EXIT"
exit 1
fi
LOG='/www/apache_log'
HOUR="`seq -w 0 23`"
files="`ls -trl ${LOG}/web-?*.log | awk '{print $9}'`"
url="$1"
export LOG HOUR files url
for file in $files
do
for a in ${HOUR}
do
num=`cat ${file} |awk '{print $4"t"$7}' |grep "${url}"|grep "/2009:${a}"|wc -l`
echo "${file}:${a} ${num}"
echo "---"
done
echo "====================================================================="
done
##########################################分钟统计指定url访问次数
# $1 url
# $2 yyyy:HH
#!/bin/sh
if [ "$1" = "" ] || [ "$2" = "" ]
then
echo "avg is null ... EXIT"
exit 1
fi
url="$1"
DATE="$2"
LOG='/www/apache_log'
M="`seq -w 0 59`"
files="`ls -trl ${LOG}/web-?*.log | awk '{print $9}'`"
export LOG HOUR files url
for file in $files
do
for a in ${M}
do
num=`cat ${file} |awk '{print $4"t"$7}' |grep "${url}"|grep "${DATE}:${a}"|wc -l`
echo "${file}:${DATE}:${a} ${num}"
echo "---"
done
echo "====================================================================="
done