分析APACHE NGINX的LOG

來源:互聯網
上載者:User

標籤:nginx   日誌分析   

1、查看當天有多少個IP訪問:

awk ‘{print $1}‘ log_file|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,查看apache進程:

ps aux | grep httpd | grep -v grep | wc -l


9,查看80連接埠的tcp串連:

netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l


10,通過日誌查看當天ip串連數,過濾重複:

cat access_log | grep "20/Oct/2008" | awk ‘{print $2}‘ | sort | uniq -c | sort -nr


11,當天ip串連數最高的ip都在幹些什麼(原來是蜘蛛):

cat access_log | grep "20/Oct/2008:00" | grep "122.102.7.212" | awk ‘{print $8}‘ | sort | uniq -c | sort -nr | head -n 10


12,當天訪問頁面排前10的url:

cat access_log | grep "20/Oct/2008:00" | awk ‘{print $8}‘ | sort | uniq -c | sort -nr | head -n 10


13,用tcpdump嗅探80連接埠的訪問看看誰最高

tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." ‘{print $1"."$2"."$3"."$4}‘ | sort | uniq -c | sort -nr


接著從日誌裡查看該ip在幹嘛:

cat access_log | grep 122.102.7.212| awk ‘{print $1"\t"$8}‘ | sort | uniq -c | sort -nr | less


14,查看某一時間段的ip串連數:

grep "2006:0[7-8]" www20060723.log | awk ‘{print $2}‘ | sort | uniq -c| sort -nr | wc -l


本文出自 “亮公子” 部落格,請務必保留此出處http://iyull.blog.51cto.com/4664834/1864369

分析APACHE NGINX的LOG

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.