Count nginx Log list IP access requests ranking

Source: Internet
Author: User

Here's my screenshot of the Nginx log.

127.0.0.1- - [ -/jan/ -:Ten: Wu: Geneva+0800]"get/http/1.1"  $ 20808 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"127.0.0.1- - [ -/jan/ -:Ten: Wu:Geneva+0800]"Get/favicon.ico http/1.1" 404 151 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"127.0.0.1- - [ -/jan/ -:Ten: Wu: the+0800]"get/index.php http/1.1"  $ 20806 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"127.0.0.1- - [ -/jan/ -:Ten: Wu: at+0800]"get/index.html http/1.1" 404 151 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"127.0.0.1- - [ -/jan/ -:Ten: About: ,+0800]"get/index.html http/1.1"  $  $ "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"127.0.0.1- - [ -/jan/ -: One: to: -+0800]"get/http/1.1"  $  $ "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: One+0800]"get/http/1.1"  $  $ "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: One+0800]"Get/favicon.ico http/1.1" 404 151 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: One+0800]"Get/favicon.ico http/1.1" 404 151 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: the+0800]"get/http/1.1" 304 0 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: -+0800]"get/http/1.1" 304 0 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: One: -: -+0800]"get/http/1.1" 304 0 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: A: -: -+0800]"get/http/1.1" 304 0 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"192.168.60.200- - [ -/jan/ -: A: -: $+0800]"get/http/1.1" 304 0 "-" "mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) gecko/20100101 firefox/31.0"

Method One:

' {++s[$1]} END {for (a in S) print A,s[a]} ' 2 192.168. 60.200 8 127.0. 0.1 6

Method Two:

' {print $} ' nginx.log|sort|uniq-c|sort-nr-K1      8192.168.  60.200      6127.0.  0.1

Method Three:

' s/--.*$//g ' nginx.log|sort|uniq-c|sort-nr-K1      8192.168.  60.200       6127.0.  0.1

Reference: http://oldboy.blog.51cto.com/2561410/1184206

http://oldboy.blog.51cto.com/blog/2561410/1184177

Count nginx Log list IP access requests ranking

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.