1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| # 列出当天访问次数最多的IP命令 root@zhiqiang.wang:~# # cut -d- -f 1 access.log | uniq -c | sort -rn | head -20
# 查看当天有多少个IP访问 root@zhiqiang.wang:~# # awk '{print $1}' access.log | sort | uniq | wc -l
# 查看某一个页面总计被访问的次数 root@zhiqiang.wang:~# # cat access.log | grep "index.php" | wc -l
# 查看每一个IP访问了多少个页面 root@zhiqiang.wang:~# # awk '{++S[$1]} END {for (a in S) print a,S[a]}' access.log
# 将每个IP访问的页面数进行从小到大排序 root@zhiqiang.wang:~# # awk '{++S[$1]} END {for (a in S) print S[a],a}' access.log | sort -n
# 查看某一个IP访问了哪些页面 root@zhiqiang.wang:~# # grep "^192.168.1.2" access.log | awk '{print $1,$7}'
# 去掉搜索引擎统计当天的页面 root@zhiqiang.wang:~# # awk '{print $12,$1}' access.log | grep ^"Mozilla" | awk '{print $2}' |sort | uniq | wc -l
# 查看21/Nov/2019:03:40:26这一个小时内有多少IP访问 root@zhiqiang.wang:~# # awk '{print $4,$1}' access.log | grep "21/Nov/2019:03:40:26" | awk '{print $2}'| sort | uniq | wc -l Nginx日志统计:
# 列出所有的IP访问情况 root@zhiqiang.wang:~# # awk '{print $1}' access.log | sort -n | uniq
# 查看访问最频繁的前100个IP root@zhiqiang.wang:~# # awk '{print $1}' access.log | sort -n | uniq -c | sort -rn | head -n 100
# 查看访问100次以上的IP root@zhiqiang.wang:~# # awk '{print $1}' access.log | sort -n | uniq -c | awk '{if($1 >100) print $0}' | sort -rn
# 查询某个IP的详细访问情况,按访问频率排序 root@zhiqiang.wang:~# # grep '192.168.1.2' access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -n 100
# 页面访问统计:查看访问最频繁的前100个页面 root@zhiqiang.wang:~# # awk '{print $7}' access.log | sort | uniq -c | sort -rn | head -n 100
# 页面访问统计:查看访问最频繁的前100个页面(排除php|py) root@zhiqiang.wang:~# # grep -E -v ".php|.py" access.log | awk '{print $7}' | sort |uniq -c | sort -rn | head -n 100
# 页面访问统计:查看页面访问次数超过100次的页面 root@zhiqiang.wang:~# # cat access.log | cut -d ' ' -f 7 | sort |uniq -c | awk '{if ($1 > 100) print$0}'
# 页面访问统计:查看最近1000条记录中,访问量最高的页面 root@zhiqiang.wang:~# # tail -1000 access.log | awk '{print $7}' | sort | uniq -c | sort -nr
# 每秒请求量统计:统计每秒的请求数前100的时间点(精确到秒) root@zhiqiang.wang:~# # awk '{print $4}' access.log | cut -c14-21 | sort | uniq -c | sort -nr | head -n 100
# 每分钟请求量统计 11、统计每分钟的请求数,top100的时间点(精确到分钟) root@zhiqiang.wang:~# # awk '{print $4}' access.log | cut -c14-18 | sort | uniq -c | sort -nr | head -n 100
# 每小时请求量统计 12、统计每小时的请求数,top100的时间点(精确到小时) root@zhiqiang.wang:~# # awk '{print $4}' access.log | cut -c14-15 | sort | uniq -c | sort -nr | head -n 100 统计其他页面数据:
# 统计网站爬虫 root@zhiqiang.wang:~# # grep -E 'Googlebot|Baiduspider' access.log | awk '{ print $1 }' | sort | uniq
# 统计网站中浏览器的访问情况 root@zhiqiang.wang:~# # cat access.log | grep -v -E 'MSIE|Firefox|Chrome|Opera|Safari|Gecko|Maxthon' | sort | uniq -c | sort -r -n | head -n 100
# 统计网段分布情况 root@zhiqiang.wang:~# # cat access.log | awk '{print $1}' | awk -F'.' '{print $1"."$2"."$3".0"}' | sort | uniq -c | sort -r -n | head -n 200
# 统计来访域名 root@zhiqiang.wang:~# # cat access.log | awk '{print $2}' | sort | uniq -c | sort -rn | more
# 统计HTTP状态 root@zhiqiang.wang:~# # cat access.log | awk '{print $9}' | sort | uniq -c | sort -rn | more
# URL访问次数统计 root@zhiqiang.wang:~# # cat access.log | awk '{print $7}' | sort | uniq -c | sort -rn | more
# URL访问流量统计 root@zhiqiang.wang:~# # cat access.log | awk '{print $7}' | egrep '?|&' | sort | uniq -c | sort -rn | more
# 文件流量统计 root@zhiqiang.wang:~# # cat access.log | awk '{sum[$7]+=$10}END{for(i in sum){print sum[i],i}}' | \ sort -rn | more | grep '200' access.log | \ awk '{sum[$7]+=$10}END{for(i in sum){print sum[i],i}}' | sort -rn | more
|