Apache 網站日志分析


1.獲得訪問前 10 位的 ip 地址

 

 

 

[root@apache ~]# cat access_log |awk '{print $1}'|sort|uniq -c|sort -nr|head -10

 

 

 

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'

 

 

Webalizer 日志分析程序

 

 

[root@Apache-Server tools]# yum install -y webalizer

 

[root@Apache-Server tools]# less /etc/webalizer.conf

 

 

 

 

http://maofan.blog.51cto.com/9212198/1560639


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM