grep "/index.php" log_file | wc -l
awk '{print $1}' |sort|uniq -c|sort -nr |head -10 access_log uniq -c 至關於分組統計並把統計數放在最前面 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<a href="http://www.lai18.com/content/,%20url%7D%3C/pre%3E%3Cbr/%3E%3Cbr/%3E9%E3%80%81%E8%AE%BF%E9%97%AE%E6%AC%A1%E6%95%B0%E6%9C%80%E5%A4%9A%E7%9A%8410%E4%B8%AA%E6%96%87%E4%BB%B6%E6%88%96%E9%A1%B5%E9%9D%A2%3Cbr/%3E%3Cbr/%3E%3Cpre%20class='brush:bash;'%3Ecat%20log_file%7Cawk%20'%7Bprint%20$11%7D'%7Csort%7Cuniq%20-c%7Csort%20-nr%20%7C%20head%20-10%20cat%20log_file%7Cawk%20'%7Bprint%20$11%7D'%7Csort%7Cuniq%20-c%7Csort%20-nr%7Chead%20-20%20awk%20'%7Bprint%20$1%7D'%20log_file%20%7Csort%20-n%20-r%20%7Cuniq%20-c%20%7C%20sort%20-n%20-r%20%7C%20head%20-20%20# 訪問量最大的前20個ip</pre><br/><br/>十、經過子域名訪問次數,依據referer來計算,稍有不許<br/><br/><pre class='brush:plain;'>cat access.log | awk '{print $11}' | sed -e ' s/http:\/\///' -e ' s/\/.*//' | sort | uniq -c | sort -rn | head -20</pre><br/><br/>十一、列出傳輸大小最大的幾個文件<br/><br/><pre class='brush:plain;'>cat <a href=" http:="" www.access.log"="" target="_blank" style="color: rgb(0, 166, 124); text-decoration: none;">www.access.log" target=_blank>, url}
cat access.log | awk '{print $11}' | sed -e ' s/http:\/\///' -e ' s/\/.*//' | sort | uniq -c | sort -rn | head -20
十一、列出傳輸大小最大的幾個文件php
<a href=", url}</pre><br/><br/>九、訪問次數最多的10個文件或頁面<br/><br/><pre class='brush:bash;'>cat log_file|awk '{print $11}'|sort|uniq -c|sort -nr | head -10 cat log_file|awk '{print $11}'|sort|uniq -c|sort -nr|head -20 awk '{print $1}' log_file |sort -n -r |uniq -c | sort -n -r | head -20 # 訪問量最大的前20個ip</pre><br/><br/>10、經過子域名訪問次數,依據referer來計算,稍有不許<br/><br/><pre class='brush:plain;'>cat access.log | awk '{print $11}' | sed -e ' s/http:\/\///' -e ' s/\/.*//' | sort | uniq -c | sort -rn | head -20</pre><br/><br/>11、列出傳輸大小最大的幾個文件<br/><br/><pre class='brush:plain;'>cat <a href=" http:="" www.access.log"="" target="_blank">cat [url=http://www.access.log]www.access.log</a> |awk '($7~/\.php/){print $10 " " $1 " " $4 " " $7}'|sort -nr|head -100
十二、列出輸出大於200000byte(約200kb)的頁面以及對應頁面發生次數html
1三、若是日誌最後一列記錄的是頁面文件傳輸時間,則有列出到客戶端最耗時的頁面apache
1四、列出最最耗時的頁面(超過60秒的)的以及對應頁面發生次數bash
1五、列出傳輸時間超過 30 秒的文件服務器
1六、列出當前服務器每一進程運行的數量,倒序排列網絡
1七、查看apache當前併發訪問數對比httpd.conf中MaxClients的數字差距多少。併發
1八、可使用以下參數查看數據tcp
統計httpd進程數,連個請求會啓動一個進程,使用於Apache服務器。表示Apache可以處理1388個併發請求,這個值Apache可根據負載狀況自動調整。網站
netstat -nat|grep -i "80"|wc -l
netstat -an會打印系統當前網絡連接狀態,而grep -i "80"是用來提取與80端口有關的鏈接的,wc -l進行鏈接數統計。最終返回的數字就是當前全部80端口的請求總數搜索引擎
netstat -na|grep ESTABLISHED|wc -l
netstat -an會打印系統當前網絡連接狀態,而grep ESTABLISHED 提取出已創建鏈接的信息。 而後wc -l統計。最終返回的數字就是當前全部80端口的已創建鏈接的總數。
netstat -nat||grep ESTABLISHED|wc
可查看全部創建鏈接的詳細記錄
1九、輸出每一個ip的鏈接數,以及總的各個狀態的鏈接數netstat -n | awk '/^tcp/ {n=split($(NF-1),array,":");if(n<=2)++S[array[(1)]];else++S[array[(4)]];++s[$NF];++N} END {for(a in S){printf("%-20s %s\n", a, S[a]);++I}printf("%-20s %s\n","TOTAL_IP",I);for(a in s) printf("%-20s %s\n",a, s[a]);printf("%-20s %s\n","TOTAL_LINK",N);}'20、其餘的收集分析日誌文件下2012-05-04訪問頁面最高的前20個URL並排序
查詢受訪問頁面的URL地址中 含有 www.abc.com 網址的 IP 地址
獲取訪問最高的10個IP地址 同時也能夠按時間來查詢
時間段查詢日誌時間段的狀況
分析2015/8/15到2015/8/16訪問"/index.php?g=Member&m=Public&a=sendValidCode"的IP倒序排列
($7~/.php/) $7裏面包含.php的就輸出,本句的意思是最耗時的一百個PHP頁面
列出最最耗時的頁面(超過60秒的)的以及對應頁面發生次數*
統計網站流量(G)
統計404的鏈接