Linux apache日志分析常用命令汇总
来源:互联网 发布:淘宝不满意怎么退货 编辑:程序博客网 时间:2024/05/01 18:44
1、查看当天有多少个IP访问:
awk '{print $1}' log_file|sort|uniq|wc –l
awk '{print $1}' dummy-host.example.com-access_log|sort|uniq|wc –l
2、查看某一个页面被访问的次数:
grep "/index.php" log_file | wc –l
3、查看每一个IP访问了多少个页面:
awk '{++S[$1]} END {for (a in S) print a,S[a]}' log_file
4、将每个IP访问的页面数进行从小到大排序:
awk '{++S[$1]} END {for (a in S) print S[a],a}' log_file | sort –n
5、查看某一个IP访问了哪些页面:
grep ^111.111.111.111 log_file| awk '{print $1,$7}'
6、去掉搜索引擎统计当天的页面:
awk '{print $12,$1}' log_file | grep ^\"Mozilla | awk '{print $2}' |sort | uniq | wc –l
7、查看2009年6月21日14时这一个小时内有多少IP访问:
awk '{print $4,$1}' log_file | grep 21/Jun/2009:14 | awk '{print $2}'| sort | uniq | wc –l
8.查看访问前十个ip地址
awk '{print $1}' |sort|uniq -c|sort -nr |head -10 log_file
9.访问次数最多的文件或页面
cat log_file |awk '{print $11}'|sort|uniq -c|sort -nr
cat dummy-host.example.com-access_log |awk '{print $11}'|sort|uniq -c|sort -nr
10.通过子域名访问次数,依据referer来计算,稍有不准
cat log_file | awk '{print $11}' | sed -e ' s/http:\/\///' -e ' s/\/.*//' | sort | uniq -c | sort -rn | head -20
11. 列出传输大小最大的几个文件
cat log_file |awk '($7~/\.php/){print $10 " " $1 " " $4 " " $7}'|sort -nr|head -100
12. 列出输出大于200000byte(约200kb)的页面以及对应页面发生次数
cat log_file |awk '($10 > 200000 && $7~/\.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100
13. 如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
cat log_file |awk '($7~/\.php/){print $NF " " $1 " " $4 " " $7}'|sort -nr|head -100
14. 列出最最耗时的页面(超过60秒的)的以及对应页面发生次数
cat log_file |awk '($NF > 60 && $7~/\.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100
15. 列出传输时间超过 30 秒的文件
cat log_file |awk '($NF > 30){print $7}'|sort -n|uniq -c|sort -nr|head -20
16. 列出当前服务器每一进程运行的数量,倒序排
ps -ef | awk -F ' ' '{print $8 " " $9}' |sort | uniq -c |sort -nr |head -20
17. 当前WEB服务器中联接次数最多的ip地址
netstat -ntu |awk '{print $5}' |sort | uniq -c| sort -nr
18. 查看日志中出现100次以上的IP
cat log_file |cut -d ' ' -f 1 |sort |uniq -c | awk '{if ($1 > 100) print $0}'|sort -nr |less
19. 查看最近访问量最高的文件
cat log_file |tail -10000|awk '{print $7}'|sort|uniq -c|sort -nr|less
cat dummy-host.example.com-access_log |tail -10000|awk '{print $7}'|sort|uniq -c|sort -nr|less
20. 查看日志中访问超过100次的页面
cat log_file | cut -d ' ' -f 7 | sort |uniq -c | awk '{if ($1 > 100) print $0}' | less
21. 统计某url,一天的访问次数
cat log_file | grep '12/Aug/2009'|grep '/images/index/e1.gif'|wc|awk '{print $1}'
22. 前五天的访问次数最多的网页
cat log_file | awk '{print $7}'|uniq -c |sort -n -r|head -20
23. 从日志里查看该ip在干嘛
cat log_file | grep 219.239.157.240 | awk '{print $1"\t"$7}' | sort | uniq -c | sort -nr | less
24. 列出最最耗时的页面(超过60秒的)
#cat log_file |awk '($NF > 60 && $7~/\.php/){print $7}' |sort -n|uniq -c|sort -nr|head -100
25. 网站一天的点击量
cat log_file |grep '12/Nov/2011' | grep "******.jsp"|wc|awk '{print $1}'|uniq
26. 访问网站的独立IP有多少
cat log_file |grep '12/Aug/2011' |grep "******"|wc|awk '{print $1}'|uniq
通过日志查看当天ip连接数,过滤重复
cat log_file | grep "20/Oct/2008" | awk '{print $2}' | sort | uniq -c | sort –nr
27. 用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort –nr
28. 查看某一时间段的ip连接数
grep "2006:0[7-8]" log_file | awk '{print $2}' | sort | uniq -c| sort -nr | wc -l
vi /var/log/httpd/www.songbaoxin.cn.access_log
awk '{a[$1]++}END {for (i in a)print i,a[i]}' /var/log/httpd/www.songbaoxin.cn.access_log| sort -k2n 查看ip有访问多少
- Linux apache日志分析常用命令汇总
- apache日志分析常用命令
- apache日志分析常用命令
- apache日志分析常用命令
- linux日志分析常用命令
- Linux日志分析常用命令
- Linux日志分析常用命令
- linux 网站日志分析常用命令
- Linux下分析日志常用命令
- 【转】linux日志分析常用命令大全
- Linux日志分析常用语句汇总
- linux apache 日志分析与状态
- Apache tomcat 日志分析(Linux环境)
- linux apache 日志分析与状态
- linux 下 grep 分析 Apache 服务器日志
- linux 分析apache访问日志脚本
- linux-linux常用命令汇总
- linux-linux常用命令汇总
- linux+nginx+mysql+php安装 以及常见问题得解决方案
- oracle 字符集
- spring 源码学习1
- Fabric 批量安装ZeroMQ
- 【众数】【bzoj 2945】: [Poi2000]气垫船
- Linux apache日志分析常用命令汇总
- 设计模式(Design Patterns)
- SPICE协议定义----显示通道(1)
- linux 调试环境搭建
- ArcGIS教程:“提取值到表”的工作原理
- php5.4环境下DedeCMS登录退出后台空白的解决办法汇总
- linux 模拟弱网络环境工具
- “刷榜客”-- 手机木马Google Play恶意刷榜
- HttpPSocket