安装autofs服务时,出现需要先安装libhesiod.so.0的解决方法
2013-03-01 14:36
381 查看
1.查看TCP连接状态
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rnnetstat -n | awk '/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}' 或
netstat -n | awk '/^tcp/ {++state[$NF]}; END {for(key in state) print key,"\t",state[key]}'
netstat -n | awk '/^tcp/ {++arr[$NF]};END {for(k in arr) print k,"\t",arr[k]}'netstat -n |awk '/^tcp/ {print $NF}'|sort|uniq -c|sort -rnnetstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c
2.查找请求数请20个IP(常用于查找攻来源):
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A[i],i}' |sort -rn|head -n20
3.用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1″."$2″."$3″."$4}' | sort | uniq -c | sort -nr |head -204.查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
5.找查较多的SYN连接
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more
6.根据端口列进程
netstat -ntlp | grep 80 | awk '{print $7}' | cut -d/ -f1网站日志分析篇1(Apache):
1.获得访问前10位的ip地址
cat access.log|awk '{print $1}'|sort|uniq -c|sort -nr|head -10
cat access.log|awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}'
2.访问次数最多的文件或页面,取前20
cat access.log|awk '{print $11}'|sort|uniq -c|sort -nr|head -20
3.列出传输最大的几个exe文件(分析下载站的时候常用)
cat access.log |awk '($7~/\.exe/){print $10 " " $1 " " $4 " " $7}'|sort -nr|head -20
4.列出输出大于200000byte(约200kb)的exe文件以及对应文件发生次数
cat access.log |awk '($10 > 200000 && $7~/\.exe/){print $7}'|sort -n|uniq -c|sort -nr|head -100
5.如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
cat access.log |awk '($7~/\.php/){print $NF " " $1 " " $4 " " $7}'|sort -nr|head -100
6.列出最最耗时的页面(超过60秒的)的以及对应页面发生次数
cat access.log |awk '($NF > 60 && $7~/\.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100
7.列出传输时间超过 30 秒的文件
cat access.log |awk '($NF > 30){print $7}'|sort -n|uniq -c|sort -nr|head -20
8.统计网站流量(G)
cat access.log |awk '{sum+=$10} END {print sum/1024/1024/1024}'
9.统计404的连接
awk '($9 ~/404/)' access.log | awk '{print $9,$7}' | sort
10. 统计http status.
cat access.log |awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}'
cat access.log |awk '{print $9}'|sort|uniq -c|sort -rn
10.蜘蛛分析查看是哪些蜘蛛在抓取内容。
/usr/sbin/tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E 'bot|crawler|slurp|spider'
网站日分析2(Squid篇)
按域统计流量
zcat squid_access.log.tar.gz| awk '{print $10,$7}' |awk 'BEGIN{FS="[ /]"}{trfc[$4]+=$1}END{for(domain in trfc){printf "%s\t%d\n",domain,trfc[domain]}}'
效率更高的perl版本请到此下载:http://docs.linuxtone.org/soft/tools/tr.pl
数据库篇1.查看数据库执行的sql
/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'
系统Debug分析篇1.调试命令
strace -p pid
2.跟踪指定进程的PID
gdb -p pid
本文出自 “jimmyliang” 博客,请务必保留此出处http://jimmyliang6293.blog.51cto.com/10319813/1695617
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rnnetstat -n | awk '/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}' 或
netstat -n | awk '/^tcp/ {++state[$NF]}; END {for(key in state) print key,"\t",state[key]}'
netstat -n | awk '/^tcp/ {++arr[$NF]};END {for(k in arr) print k,"\t",arr[k]}'netstat -n |awk '/^tcp/ {print $NF}'|sort|uniq -c|sort -rnnetstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c
2.查找请求数请20个IP(常用于查找攻来源):
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A[i],i}' |sort -rn|head -n20
3.用tcpdump嗅探80端口的访问看看谁最高
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1″."$2″."$3″."$4}' | sort | uniq -c | sort -nr |head -204.查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
5.找查较多的SYN连接
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more
6.根据端口列进程
netstat -ntlp | grep 80 | awk '{print $7}' | cut -d/ -f1网站日志分析篇1(Apache):
1.获得访问前10位的ip地址
cat access.log|awk '{print $1}'|sort|uniq -c|sort -nr|head -10
cat access.log|awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}'
2.访问次数最多的文件或页面,取前20
cat access.log|awk '{print $11}'|sort|uniq -c|sort -nr|head -20
3.列出传输最大的几个exe文件(分析下载站的时候常用)
cat access.log |awk '($7~/\.exe/){print $10 " " $1 " " $4 " " $7}'|sort -nr|head -20
4.列出输出大于200000byte(约200kb)的exe文件以及对应文件发生次数
cat access.log |awk '($10 > 200000 && $7~/\.exe/){print $7}'|sort -n|uniq -c|sort -nr|head -100
5.如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
cat access.log |awk '($7~/\.php/){print $NF " " $1 " " $4 " " $7}'|sort -nr|head -100
6.列出最最耗时的页面(超过60秒的)的以及对应页面发生次数
cat access.log |awk '($NF > 60 && $7~/\.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100
7.列出传输时间超过 30 秒的文件
cat access.log |awk '($NF > 30){print $7}'|sort -n|uniq -c|sort -nr|head -20
8.统计网站流量(G)
cat access.log |awk '{sum+=$10} END {print sum/1024/1024/1024}'
9.统计404的连接
awk '($9 ~/404/)' access.log | awk '{print $9,$7}' | sort
10. 统计http status.
cat access.log |awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}'
cat access.log |awk '{print $9}'|sort|uniq -c|sort -rn
10.蜘蛛分析查看是哪些蜘蛛在抓取内容。
/usr/sbin/tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E 'bot|crawler|slurp|spider'
网站日分析2(Squid篇)
按域统计流量
zcat squid_access.log.tar.gz| awk '{print $10,$7}' |awk 'BEGIN{FS="[ /]"}{trfc[$4]+=$1}END{for(domain in trfc){printf "%s\t%d\n",domain,trfc[domain]}}'
效率更高的perl版本请到此下载:http://docs.linuxtone.org/soft/tools/tr.pl
数据库篇1.查看数据库执行的sql
/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'
系统Debug分析篇1.调试命令
strace -p pid
2.跟踪指定进程的PID
gdb -p pid
本文出自 “jimmyliang” 博客,请务必保留此出处http://jimmyliang6293.blog.51cto.com/10319813/1695617
相关文章推荐
- 系统恢复后,通过sqlserver服务管理器启动出现“指定的服务未安装”的解决方法
- Windows 2008R2 安装Active Directory 域服务出现二进制文件失败解决方法
- 安装SQL server 2005 出现警告 32位ASP.NET已经注册,需要注册64位的解决方法
- 卸载时候出现: windows installer 程序有问题。此安装需要的dll不能运行 的一个解决方法
- Microsoft Dynamics CRM 2013 安装 报表服务出现“ SQL Server Reporting Services 帐户是本地用户且不受支持 ”错误的解决方法
- tomcat7w.exe 出现指定的服务未安装的解决方法
- SQL Server启动出现“指定的服务未安装”的解决方法
- 安装JDK出现"Windows Installer程序包有问题,此安装需要的DLL不能运行"解决方法
- 安装JDK出现"Windows Installer程序包有问题,此安装需要的DLL不能运行"解决方法
- 安装Office时出现windows installer服务不能更新一个或多个受保护的windows文件错误的解决方法
- XP系统安装Office 2010出现:windows installer服务不能更新一个或多个受保护的windows文件 解决方法
- 安装SQL Server 2005时,出现“SQL Server 服务无法启动。……”提示的解决方法
- mysql+Apache+php环境配置中安装Apache,注册服务出现“(OS 5)拒绝访问的解决方法
- 安装额外DC时出现"RPC服务不可用"解决方法
- SQL Server2000安装过程中出现”挂起 需要重新启动“的解决方法
- [导入]出现windows启动服务失败(无法从命令行或调试器启动,需要安装InstallUtil.exe)的解决办法
- 安装PL-2303出现“需要ser2pl.sys”的解决方法
- 安装额外DC时出现"RPC服务不可用"解决方法
- 安装最新MSN8.5时候出现上述提示 “需要安装 Windows Update Agent 5.8.02469或更高版本"的解决方法
- [导入]出现windows启动服务失败(无法从命令行或调试器启动,需要安装InstallUtil.exe)的解决办法