NGINX結合SHELL統計使用者的UV及IP匯總

來源:互聯網
上載者:User

標籤:

公司新的需求,懷疑PV和IP的比例不對,看是不是有惡意的東東:

NGINX配置:

 

log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘                      ‘$status $body_bytes_sent "$http_referer" ‘                      ‘"$http_user_agent" "$http_x_cookie" "$request_time" "$upstream_response_time" "$upstream_cache_status" "$uid"‘;
set $uid "-";        if ( $http_cookie ~* "uid=(\S+)(;.*|$)"){            set $uid $1;        }    

 

PV前二十位熱門排行榜:

cat test.log|sort|awk ‘$NF!~/-/ {print $1"," $NF}‘|uniq |awk -F  , ‘{print $1}‘|uniq -c|sort -nr|head -20

12     53.27.4.22
1     61.183.86.163
1     61.183.237.146
1     58.255.215.115
1     27.154.152.131
1     223.240.50.192
1     222.94.205.228
1     219.140.69.67
1     218.89.115.155
1     218.28.77.119
1     183.63.212.176
1     183.54.95.254
1     182.107.39.76
1     163.179.53.171
1     14.130.237.192
1     124.207.249.82
1     124.128.87.134
1     124.117.198.63
1     122.224.216.242
1     121.61.112.2

 

公司總的IP數:

cat test.log|sort|awk ‘$NF!~/-/ {print $1"," $NF}‘|uniq |awk -F  , ‘{print $1}‘|uniq -c|sort -nr|wc -l

32

公司總的UV數:

cat test.log|sort|awk ‘$NF!~/-/ {print $1"," $NF}‘|uniq |awk -F  , ‘{print $1}‘|uniq -c|sort -nr|awk ‘BEGIN{total=0}{total=total+$1}END{print "UV is:" total}‘

UV is:43

 

NGINX結合SHELL統計使用者的UV及IP匯總

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.