统计 PV、uv、独立ip
一、对pv、uv、独立访问ip的了解。
1、UV(Unique Visitor):独立访客,将每个独立上网电脑(cookie)视为一个独立访客,一天24小时之内,访问自己网站的访客数量。(相同cookie一天只被统计一次)
2、PV(Page View):访问量,即页面浏览量或者点击量,用户每次对网站的访问均被记录1次。用户对同一页面的多次访问,统计量累积。
3、独立IP:一天内相同ip地址只被计算一次。
二、日志输出格式:
139.205.177.97 - - [21/Jun/2020:03:20:10 +0800] "GET /Public/home/appjs/Index.js HTTP/1.1" 404 304 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; KB974488)" 2.187.59.113 - - [21/Jun/2020:03:48:15 +0800] "GET / HTTP/1.1" 200 2398 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" 163.179.54.214 - - [21/Jun/2020:03:53:51 +0800] "GET /swagger/docs/v1 HTTP/1.1" 400 301 "-" "-" 45.141.86.190 - - [21/Jun/2020:04:06:42 +0800] "\x03" 400 301 "-" "-" 41.90.115.94 - - [21/Jun/2020:04:12:11 +0800] "GET / HTTP/1.1" 200 2398 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" 46.166.128.174 - - [21/Jun/2020:04:49:28 +0800] "GET /post-sitemap2.xml HTTP/1.1" 400 301 "-" "-" 37.49.226.227 - - [21/Jun/2020:05:50:59 +0800] "GET ../../proc HTTP" 400 301 "-" "-" 202.58.243.78 - - [21/Jun/2020:06:13:44 +0800] "GET / HTTP/1.1" 200 2398 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" 80.82.70.187 - - [21/Jun/2020:06:27:11 +0800] "GET http://www.baidu.com/cache/global/img/gs.gif HTTP/1.1" 404 300 "-" "Mozilla" 119.23.174.205 - - [21/Jun/2020:08:21:35 +0800] "GET / HTTP/1.0" 200 2398 "-" "-"
三、统计:
网站做好了日志切割,这里只统计当天的数据。
1、总PV量:
[root@Huawei ~]# awk '{print $6}' /var/log/httpd/access_log-20200628 | wc -l 549
2、独立IP:
[root@Huawei ~]# awk '{print $1}' /var/log/httpd/access_log-20200628 | sort -r|uniq -c | wc -l 223
3、UV统计:
[root@Huawei ~]# awk '{print $10}' /var/log/httpd/access_log-20200628 | sort -r | uniq -c | wc -l 48