• Nginx: 统计PV、UV、独立IP


    1、概念:

    1. UV(Unique Visitor):独立访客,将每个独立上网电脑(以cookie为依据)视为一位访客,一天之内(00:00-24:00),访问您网站的访客数量。一天之内相同cookie的访问只被计算1次;
    2. PV(Page View):访问量,即页面浏览量或者点击量,用户每次对网站的访问均被记录1次。用户对同一页面的多次访问,访问量值累计;
    3. 统计独立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

  • 相关阅读:
    关闭当前的子窗口,刷新父窗口,弹出层提示框
    让一个div层于窗口中间位置
    一些技术贴,留待以后研究
    什么才是程序员的核心竞争力?
    自己喜欢的编辑器字体设置
    Ajax请求状态200,却走error的函数
    20141110的alltosun面试
    匹配中文的正则表达式
    数据表损坏:Incorrect key file for table
    oracle union 和 union all
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/10272258.html
Copyright © 2020-2023  润新知