获取客户端ip访问网站的次数和请求页面
#/bin/bash
cd /data/iplog/$1/pv
txt=$(ls -l|awk ‘{print $NF}‘|sed ‘1d‘)
for n in $txt
do
ip=$(cat /root/iplist)
for n1 in $ip
do
grep $n1 $n >>/opt/txt01/$n1-$1-cpv.txt
done
done
rep_txt=$(cd /opt/txt01/&&ls -l *cpv.txt|awk ‘{print $NF}‘|sed ‘1d‘)
cd /opt/txt01
for n2 in $rep_txt
do
##cat $n2 |awk -F [/] ‘{print $3}‘|sort|uniq -c|sort -nr >>$n2-test
cat $n2|awk -F ‘[ ]+‘ ‘{print $4}‘|sort|uniq -c|sort -nr >>/opt/txt02/$n2-cpv
done
cd /opt/
tar zcf /opt/txt02/$1-$2-cpv-iplog.tar.gz ./txt02
[[email protected] test001]# cat /root/iplist
117.136.79.39
117.136.79.32
117.136.79.33
117.136.79.37
117.136.79.36
120.239.77.229
223.104.63.150
[[email protected] test001]# cd /opt/txt01/
[[email protected] txt01]# ls
117.136.79.32-2018-05-17-cpv.txt 117.136.79.36-2018-05-17-cpv.txt 117.136.79.39-2018-05-17-cpv.txt 223.104.63.150-2018-05-17-cpv.txt
117.136.79.33-2018-05-17-cpv.txt 117.136.79.37-2018-05-17-cpv.txt 120.239.77.229-2018-05-17-cpv.txt
[[email protected] txt01]# cd /opt/txt02/
[[email protected] txt02]# ls
117.136.79.33-2018-05-17-cpv.txt-cpv 117.136.79.37-2018-05-17-cpv.txt-cpv 120.239.77.229-2018-05-17-cpv.txt-cpv 223.104.63.150-2018-05-17-cpv.txt-cpv
117.136.79.36-2018-05-17-cpv.txt-cpv 117.136.79.39-2018-05-17-cpv.txt-cpv 2018-05-17-233-cpv-iplog.tar.gz
[[email protected] txt01]# head -10 /opt/txt02/117.136.79.37-2018-05-17-cpv.txt-cpv
6 http://m.31xs.net/13/13431/10319091.html
4 https://m.yubook.net/novel/61462/7938632.html
4 https://m.ybdu.com/xiaoshuo/18/18935/6895763.html
4 https://m.xiaoshuoli.com/i35445/18566473.html
4 https://m.xiaoshuoli.com/i18640/18476060.html
4 https://m.biquxu.com/24/24853/12085909.html
4 http://m.wutuxs.com/html/1/1071/842907.html
4 http://m.sanhao33.com/sort-8-5/
4 http://m.jw46.com/sort/
4 http://m.bxwx.io/book_77838/22048312.html
原文地址:http://blog.51cto.com/wujianwei/2118742
时间: 2024-10-07 10:00:05