One shell per day (vii) IP and PV for the statistics site

Source: Internet
Author: User
Tags knowledge base

Using Nginx log file to count all IP and PV, list the top 10 IP, take confluence Knowledge base system as an example:

Nginx log file is/var/log/nginx/access.log

# wc -l /var/log/nginx/access.log 95146 /var/log/nginx/access.log

Shell script:

# vim accessnum.sh #!/bin/bash#writen by Gavin Zhao#This shell will print how many users access your server by webawk ‘/itks/ {print $1}‘ /var/log/nginx/access.log | sort -rn | uniq -c | sort -rn | awk ‘{$2 ~ /10./ && $2!="10.1.46.189" && (tot=tot+$0)};END{print NR,tot}‘  > /root/script/num.txt 2> /dev/nullip=`awk ‘{print $1}‘ /root/script/num.txt`pv=`awk ‘{print $2}‘ /root/script/num.txt`echo "截止到目前IT知识库的总访问量:$pv"echo "截止到目前IT知识库的总访问IP数:$ip"echo "排名前10的IP如下:"awk ‘/itks/ {print $1}‘ /var/log/nginx/access.log | sort -rn | uniq -c | sort -rn | awk ‘ $2 ~ /10./ && $2 !~ /10.1.46.189|10.1.116.4/ && NR<=12 {print $2}‘
chmod +x accessnum.sh

One shell per day (vii) IP and PV for the statistics site

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.