CentOS網站伺服器維護必備解決方案及日誌分析

來源:互聯網
上載者:User

CentOS網站伺服器維護必備解決方案及日誌分析
日誌分析命令

分析URL(504錯誤,大於500的錯誤可直接寫成5..)
下面命令是發生504錯誤的url列表。

awk '$10 ~ /504/ { print $8}' xxx_com_access.log-${date} | awk -F "&" '{print $1,$2}' | sort  | uniq -c | sort -rn | head -10 


分析伺服器回應時間(大於100ms)
下面命令是顯示回應時間大於100ms的伺服器列表。

awk '{if($NF>0.10) print $(NF-1)}' xxx_com_access.log | uniq -c | sort -n 

找出訪問次數最多的幾個分鐘:

awk '{print $5}' xxxx_com_access.log |cut -c 14-18|sort|uniq -c|sort -nr|head


日誌中ip地址訪問最多的top15

awk '{ip[$2]++} ; END{ for (i in ip) print ip[i],i }' xxx_access.log-20130922  | sort -n | tail -n 15


可疑ip的分析

ip地址對應的用戶端mac地址的統計:awk '$2 ~ /219.148.23.36/ {print $2,$8}' xxxx_access.log-20130922  | grep mac= | awk -F "=" '{print $(NF-1)}' | grep -v mac | cut -c 1-17 | sort |uniq -c | sort –nip地址對應的user-agent的統計:awk '$2 ~ /111.30.132.190/ {print $2,$5,$15,$16,$17,$18,$19,$20}' xxx_com_access.log-20130922  | more

另外還有:

當前訪問量最大的ip:tcpdump -i em1 -tnn dst port 80 -c 100000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 15找出這個ip正在幹什麼:cd /data/logs/xxx ; tail -n 10000000 xxx_com_access.log | grep 123.150.205.205 | awk '{print $2"\t"$8}' | sort | uniq -c | sort –nr

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.