Linux analytics logs get the top 10 IP for most accesses

Source: Internet
Author: User
Tags apache log

Original address: http://xuqq999.blog.51cto.com/3357083/774714

Apache Log analysis can get a lot of useful information, now to try the most basic, get the most access to the top 10 IP address and number of visits.

Since it is statistical, awk is essential, useful and efficient.

The command is as follows:

awk ' {a[$1] + = 1;} END {for (I in a) printf ("%d%s\n", a[i], i);} ' log file | Sort-n | Tail

First, you use awk to get a list, then sort it out, and finally use tail to take the last 10.

The above parameters can be slightly modified to display more data, such as the tail plus-n parameters, and other log format commands may need to be modified.

the most frequently joined IP addresses in the current Web server

#netstat-ntu |awk ' {print $} ' |sort | uniq-c| Sort-nr

View the top 10 most visited IPs in a log

#cat access_log |cut-d '-F 1 | Sort |uniq-c | Sort-nr | awk ' {print $} ' | Head-n 10 | Less

See more than 100 IPs in the log

#cat access_log |cut-d '-F 1 | Sort |uniq-c | awk ' {if (>) Print $ |SORT-NR | Less

View the most recently accessed files

#cat Access_log | tail-10000 | awk ' {print $7} ' | Sort | uniq-c | Sort-nr | Less

View pages that have been accessed more than 100 times in the log

#cat Access_log | Cut-d '-F 7 | Sort |uniq-c | awk ' {if (>) print $} ' | Less

Statistics a URL, the number of visits per day

#cat Access_log | grep ' 12/aug/2009 ' | grep '/images/index/e1.gif ' | WC | awk ' {print '} '

Most visited pages in the first five days

#cat Access_log | awk ' {print $7} ' | uniq-c | Sort-n-R | Head-20

See what the IP is doing in the log.

#cat Access_log | grep 218.66.36.119 | awk ' {print ' \ t ' $7} ' | Sort | uniq-c | Sort-nr | Less

List files that have been transmitted for longer than 30 seconds

#cat Access_log | awk ' ($NF >) {print $7} ' | Sort-n | uniq-c | Sort-nr | Head-20

List the most time-consuming pages (more than 60 seconds)

#cat Access_log | awk ' ($NF > && $7~/\. php/) {print $7} ' | Sort-n | uniq-c | Sort-nr | head-100

Linux analytics logs get the top 10 IP for most accesses

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.