1、概念:
- UV(Unique Visitor):獨立訪客,將每個獨立上網電腦(以cookie為依據)視為一位訪客,一天之內(00:00-24:00),訪問您網站的訪客數量。一天之內相同cookie的訪問只被計算1次;
- PV(Page View):訪問量,即頁面瀏覽量或者點擊量,用戶每次對網站的訪問均被記錄1次。用戶對同一頁面的多次訪問,訪問量值累計;
- 統計獨立IP:00:00-24:00內相同IP地址只被計算一次,做網站優化的朋友最關心這個;
2、日志輸出格式:
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx HTTP/1.1" 302 5 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:57:20 +0800] "GET /ljzx/logout HTTP/1.1" 200 9228 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:58:20 +0800] "GET / HTTP/1.1" 302 0 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
172.16.0.70 - - [03/Jan/2019:23:58:20 +0800] "GET /ljzx HTTP/1.1" 302 5 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
...
3、統計
總PV量:
[root@localhost logs]# awk '{print $6}' host.access.log | wc -l
獨立IP:
[root@localhost logs]# awk '{print $1}' host.access.log | sort -r |uniq -c | wc -l
UV統計:
[root@localhost logs]# awk '{print $10}' host.access.log | sort -r |uniq -c |wc -l