- 論壇徽章:
- 0
|
自己用shell寫了一個,但是文件一大,處理速度太慢。只實現(xiàn)了對ip排序和對每個ip訪問的域名統(tǒng)計20個,沒有排序,也沒有對時間過濾。
發(fā)出來,請高手指點一下。
#!/bin/sh
SLog="/home/tony/shell/log/test.log"
IPs=`awk '{ print $1 }' $SLog | sort | uniq`
Doms=`awk -F"/" '{ print $5 }' $SLog | sort | uniq | grep -E "^[a-zA-Z0-9][a-z0-9]{0,}.\W.{1,}(com|cn|com.cn|net)$"`
#Doms=`awk '{ print $2 }' $SLog | sort | uniq`
#echo $Doms
echo -e "+-----------------+-----------------------------+-------+"
echo -e "| IP | Site and Domain | Count |"
echo -e "+-----------------+-----------------------------+-------+"
for ip in $IPs
do
#ip_total=`grep "$ip" $SLog | wc -l`
#echo -e "$ip\t$ip_total"
for dom in $Doms
do
i=1
count=`grep "$ip" $SLog | grep "$dom" | wc -l`
if [ "$i" -lt 20 ]
then
if [ "$count" -gt 0 ]
then
echo -e "| $ip | $dom | $count |"
echo -e "+-----------------+-----------------------------+-------+"
fi
((i++))
fi
done
done |
|
|