DevOps-田飞雨


  • Home

  • Archives

  • Tags

常用Linux系统Debug命令

Posted on 2016-07-17

1、查看TCP连接状态
netstat -nat |awk ‘{print $6}’|sort|uniq -c|sort -rn
netstat -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 -rn
netstat -ant | awk ‘{print $NF}’ | grep -v ‘[a-z]’ | sort | uniq -c
netstat -nat |awk ‘{print $6}’|sort|uniq -c|sort -rn
netstat -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 -rn
netstat -ant | awk ‘{print $NF}’ | grep -v ‘[a-z]’ | sort | uniq -c

2、查找请求80端口最多的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}’ |sort -rn|head -n20
tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F”.” ‘{print $1”.”$2”.”$3”.”$4}’ | sort | uniq -c | sort -nr |head -n 20

3、查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk ‘{print $5}’|sort|uniq -c|sort -rn|head -n20

4、找查较多的SYN连接
netstat -an | grep SYN | awk ‘{print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -nr | more

5、根据端口列进程
netstat -ntlp | grep 80 | awk ‘{print $7}’ | cut -d/ -f1

6、获取Web访问前10位的ip地址
cat access.log|awk ‘{print $1}’|sort|uniq -c|sort -nr|head -n 10
cat access.log|awk ‘{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}’

​7、访问次数最多的文件或页面,取前20
cat access.log|awk ‘{print $11}’|sort|uniq -c|sort -nr|head -n 20

8、列出传输最大的几个rar文件
cat access.log|awk ‘{print $11}’|sort|uniq -c|sort -nr|head -n 20

9、列出输出大于200000byte(约200kb)的rar文件以及对应文件发生次数
cat access.log |awk ‘($10 > 200000 && $7~/.rar/){print $7}’|sort -n|uniq -c|sort -nr|head -n 100

10、如果日志最后一列记录的是页面文件传输时间,则有列出到客户端最耗时的页面
cat access.log |awk ‘($7~/.php/){print $NF “ “ $1 “ “ $4 “ “ $7}’|sort -nr|head -n 100
cat access.log |awk ‘($7~/.php/){print $NF “ “ $1 “ “ $4 “ “ $7}’|sort -nr|head -n 100

11、列出最最耗时的页面(超过60秒的)的以及对应页面发生次数
cat access.log |awk ‘($NF > 60 && $7~/.php/){print $7}’|sort -n|uniq -c|sort -nr|head -n 100

12、列出传输时间超过 30 秒的文件
cat access.log |awk ‘($NF > 30){print $7}’|sort -n|uniq -c|sort -nr|head -n 20

13、统计网站流量(G)
cat access.log |awk ‘{sum+=$10} END {print sum/1024/1024/1024}’

14、统计404的连接
awk ‘($9 ~/404/)’ access.log | awk ‘{print $9,$7}’ | sort

15、统计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

16、查看是哪些爬虫在抓取内容
tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E ‘bot|crawler|slurp|spider’

17、查看数据库执行的sql语句
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'

18、按域统计流量
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]}}'

19、调试命令
strace -p pid

20、磁盘性能
iostat -x 1 10

git 使用指南及高级技巧

Posted on 2016-07-14

###github 详细操作 : https://github.com/lavor-zl/Github-Git

##git 高级教程: http://mp.weixin.qq.com/s?__biz=MzA3OTgyMDcwNg==&mid=2650625356&idx=1&sn=32e5a0550b08fab554edb5f31cfd54a5&scene=2&srcid=0608JkN5HRfOV5POEyd2tClo&from=timeline&isappinstalled=0#wechat_redirect

##Q:配置用户名和密码

git config --global user.name "strugglingyouth"
git config --global user.email "630441839@qq.com"
git config --list
git config --global color.ui true

##Q: 绑定远程分支,不用每次pull或push时指定

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

##Q:合并远程分支到当前分支

git merge origin/master 
# 或者
$ git rebase origin/master

##Q:删除追踪状态的文件

git rm --cached *.pyc

##Q:今天使用github的pages功能搞了一个blog,用了github提供的主题,当我将其git clone下来的时候,出现:

# On branch master
# Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   fonts/OpenSans-Bold-webfont.eot
    #       modified:   fonts/OpenSans-Bold-webfont.svg
    #       modified:   fonts/OpenSans-Bold-webfont.ttf
    #       modified:   fonts/OpenSans-Bold-webfont.woff
    #       modified:   fonts/OpenSans-BoldItalic-webfont.eot
    #       modified:   fonts/OpenSans-BoldItalic-webfont.svg
    #       modified:   fonts/OpenSans-BoldItalic-webfont.ttf
    #       modified:   fonts/OpenSans-BoldItalic-webfont.woff
    #       modified:   fonts/OpenSans-Italic-webfont.eot
    #       modified:   fonts/OpenSans-Italic-webfont.svg
    #       modified:   fonts/OpenSans-Italic-webfont.ttf
    #       modified:   fonts/OpenSans-Italic-webfont.woff
    #       modified:   fonts/OpenSans-Regular-webfont.eot
    #       modified:   fonts/OpenSans-Regular-webfont.svg
田飞雨

田飞雨

DevOps

2 posts
RSS
© 2016 田飞雨
Powered by Hexo
Theme - NexT.Muse