国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux Web服務器網站故障分析常用命令

2019-11-02 16:22:56
字體:
來源:轉載
供稿:網友

Linux Web服務器網站故障分析,具體內容如下

系統連接狀態篇:

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 -n20netstat -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 -20

4.查找較多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 -10cat 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

11.蜘蛛分析,查看是哪些蜘蛛在抓取內容。

/usr/sbin/tcpdump -i eth0 -l -s 0 -w - dst port 80 | strings | grep -i user-agent | grep -i -E 'bot|crawler|slurp|spider'

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 肇东市| 保亭| 中方县| 金华市| 弋阳县| 东兴市| 莱阳市| 刚察县| 天台县| 涪陵区| 巴塘县| 浑源县| 通州市| 郯城县| 安阳市| 克拉玛依市| 融水| 邵东县| 西华县| 嘉荫县| 黎平县| 昌宁县| 辽中县| 宁陵县| 石家庄市| 安乡县| 象州县| 姚安县| 乌拉特后旗| 博乐市| 壶关县| 渭南市| 称多县| 长顺县| 定南县| 肃南| 武穴市| 陇南市| 磐安县| 南华县| 山阴县|