Count the number of IP and per-address accesses through the access log Access.log
101.226.61.184 - - [22/nov/2015:11:02:00 +0800] "Get /mobile/sea-modules/gallery /zepto/1.1.3/zepto.js http/1.1 " 200 24662 " http://m.oldboyedu.com/mobile/theme/oldboyedu/ Home/index.html " " mozilla/5.0 (linux; u; android 5.1.1; zh-cn; huawei crr-ul00 build/huaweicrr-ul00) AppleWebKit/533.1 (Khtml, like gecko) version/4.0 mqqbrowser/5.4 tbs/025478 mobile safari/533.1 micromessenger/6.3.7.51_rbb7fa12.660 NETTYPE/3GNET LANGUAGE/ZH_CN "101.226.61.184 - - [22/nov/2015:11:02:00 +0800] " get /mobile/theme/oldboyedu/common/js/baiduanalytics.js http/1.1 " 200 526 "/http M.oldboyedu.com/mobile/theme/oldboyedu/home/index.html " " mozilla/5.0 (linux; u; android 5.1.1; zh-cn; huawei crr-ul00 build/huaweicrr-ul00) AppleWebKit/533.1 ( Khtml, like geCKO) version/4.0 mqqbrowser/5.4 tbs/025478 mobile safari/533.1 micromessenger/6.3.7.51 _RBB7FA12.660 NETTYPE/3GNET LANGUAGE/ZH_CN "
Method 1:
awk ' {s[$1]++}end{for (i in s) print S[i],i} ' access.log |sort-rn5 101.226.61.1842 27.154.190.1582 218.79.64.761 114.94. 29.165
Method 2:
awk ' {print '} ' access.log |sort|uniq-c|sort-rn 5 101.226.61.184 2 27.154.190.158 2 218.79.64.76 1 114.94.29.165
The awk array is not quite understood yet?
Previous issue:awk Array Statistics
Previous topic:awk Cumulative Additions
Frequently asked Questions: Beginner awk arrays will encounter several common problems
today is a day to accompany everyone's first day, look forward to your progress.
For questions and answers, please leave a comment in the blog comments section.
Index of the topic of the previous period
http://lidao.blog.51cto.com/3388056/1914205
This article is from the "Lee blog" blog, make sure to keep this source http://lidao.blog.51cto.com/3388056/1919766
Old boy Education Daily-April 26, 2017-count the number of IP and per-address accesses by accessing the log Access.log