zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    MongoClient类
    MongoDB基本操作(增删改查)
    为什么MongoDB适合大数据的存储?
    npm的使用
    nodejs安装教程
    c#byte数组和string类型转换
    C#中数组、ArrayList和List三者的区别
    eclspse魔板
    mysql的备份
    shell的使用
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/10272258.html
Copyright © 2011-2022 走看看