Nginx Access log Log Statistics Analysis Common command Nginx Access log log Statistics analysis Common command IP related statistics
Statistics IP Traffic
awk ' {print '} ' Access.log | Sort-n | Uniq | Wc-l
View IP traffic for a time period (4-5 points)
grep "07/apr/2017:0[4-5]" Access.log | awk ' {print '} ' | Sort | uniq-c| Sort-nr | Wc-l
View the top 100 most frequently visited IPs
awk ' {print '} ' Access.log | Sort-n |uniq-c | Sort-rn | Head-n 100
View IP access more than 100 times
awk ' {print '} ' Access.log | Sort-n |uniq-c |awk ' {if ($ >100) print $} ' |sort-rn
Query the detailed access of an IP, sorted by frequency of access
grep ' 104.217.108.66 ' Access.log |awk ' {print $7} ' |sort |uniq-c |sort-rn |head-n 100
Page Access Statistics
View the most frequently accessed pages (TOP100)
awk ' {print $7} ' Access.log | Sort |uniq-c | Sort-rn | Head-n 100
View the most frequently accessed pages ([Exclude PHP pages "(TOP100)
Grep-v ". php" Access.log | awk ' {print $7} ' | Sort |uniq-c | Sort-rn | Head-n 100
View pages that have visited more than 100 times
Cat Access.log | Cut-d '-F 7 | Sort |uniq-c | awk ' {if (>) print $} ' | Less
View the most recent 1000 records with the highest volume of visited pages
tail-1000 access.log |awk ' {print $7} ' |sort|uniq-c|sort-nr|less
Request Volume statistics per second
Count requests per second, Top100 Point in time (accurate to seconds)
awk ' {print $4} ' access.log |cut-c 14-21|sort|uniq-c|sort-nr|head-n 100
Request Volume statistics per minute
Count requests per minute, Top100 point in time (accurate to minutes)
awk ' {print $4} ' access.log |cut-c 14-18|sort|uniq-c|sort-nr|head-n 100
Request volume statistics per hour
Count the number of requests per hour, Top100 point in time (accurate to hours)
awk ' {print $4} ' access.log |cut-c 14-15|sort|uniq-c|sort-nr|head-n 100
Performance analysis
Add $request_time to the last field in Nginx log
List pages with transmission time exceeding 3 seconds, showing top 20
Cat Access.log|awk ' ($NF > 3) {print $7} ' |sort-n|uniq-c|sort-nr|head-20
List pages with PHP pages requesting more than 3 seconds, and count the number of times they appear, showing the top 100
Cat Access.log|awk ' ($NF > 1 && $7~/\.php/) {print $7} ' |sort-n|uniq-c|sort-nr|head-100
Spider Crawl Stats
Count Spider crawl Times
grep ' Baiduspider ' Access.log |wc-l
Count spiders to crawl 404 times
grep ' Baiduspider ' access.log |grep ' 404 ' | Wc-l
TCP Connection Statistics
To view the current number of TCP connections
Netstat-tan | grep "established" | grep ": 80" | Wc-l
Sniff 80-port access with tcpdump to see who is the tallest
Tcpdump-i ETH0-TNN DST Port 80-c 1000 | Awk-f "." ' {print $ '. $ "." $ "." $4} ' | Sort | uniq-c | Sort-nr
Http://www.cnblogs.com/coolworld/p/6726538.html
Nginx Access Log Log Statistics Analysis common commands