Apache日誌分析

2021-06-16 13:32:22 字數 2256 閱讀 4422

1、獲得訪問前10位的ip位址

cataccess.log|awk ''|sort|uniq -c|sort -nr|head -10

cat access.log|awk '; end '

2、訪問次數最多的檔案或頁面,取前20及統計所有訪問ip

cat access.log|awk ''|sort|uniq -c|sort -nr|head -20

awk '' access.log |sort -n -r |uniq -c|wc -l 3、

cat access.log |awk '($7~/\.exe/)'|sort -nr|head -20 4、

列出輸出大於200000byte(約200kb)的exe檔案以及對應檔案發生次數

cat access.log |awk '($10 > 200000 && $7~/\.exe/)'|sort -n|uniq -c|sort -nr|head -100

5、如果日誌最後一

列記錄的是頁面檔案傳輸時間,則有

列出到客戶端最耗時的頁面

cat access.log |awk '($7~/\.php/)'|sort -nr|head -100 6、

列出最最耗時的頁面(超過60秒的)的以及對應頁面發生次數

cat access.log |awk '($nf > 60 && $7~/\.php/)'|sort -n|uniq -c|sort -nr|head -100 7、

列出傳輸時間超過 30 秒的檔案

cat access.log |awk '($nf > 30)'|sort -n|uniq -c|sort -nr|head -20

8、統計**流量(g)

cat access.log |awk ' end '

9、統計404的連線

awk '($9 ~/404/)' 

access.log | awk '' | sort

10、統計http status.

cat access.log |awk '; end '

cat access.log |awk ''|sort|uniq -c|sort -rn

11、每秒併發:

awk 'end'|sort -k 2 -nr|head -n10

12、頻寬統計

cat apache.log |awk 'end'

cat apache.log |awk 'end'

13、統計物件數量及物件平均大小

cat access.log |awk 'end'

cat access.log |awk 'end

14、取5分鐘日誌

if [ $date_minute != $date_end_minute ] ;then #則判斷開始時間戳與結束時間戳是否相等start_line=`sed -n "/$date_minute/=" $apache_log|head -n1` #如果不相等,則取出開始時間戳的行號,與結束時間戳的行號

#end_line=`sed -n "/$date_end_minute/=" $apache_log|tail -n1`

end_line=`sed -n "/$date_end_minute/=" $apache_log|head -n1`sed -n "$,$p" $apache_log > $minute_log ##通過行號,取出5分鐘內的日誌內容 存放到 臨時檔案中

get_start_time=`sed -n "$p" $apache_log|awk -f '[' '' |awk ''|

sed 's#/# #g'|sed 's#:# #'` #通過行號獲取取出開始時間戳

get_end_time=`sed -n "$p" $apache_log|awk -f '[' '' |awk ''|sed

's#/# #g'|sed 's#:# #'` #通過行號獲取結束時間戳

15、蜘蛛分析

檢視是哪些蜘蛛在抓取內容

apache日誌分析

1,檢視apache程序 2,檢視80埠的tcp連線 netstat tan grep established grep 80 wc l 3,通過日誌檢視當天ip連線數,過濾重複 cat access log grep 20 oct 2008 awk sort uniq c sort nr 4,當天...

apache的日誌分析

1,檢視apache程序 2,檢視80埠的tcp連線 netstat tan grep established grep 80 wc l 3,通過日誌檢視當天ip連線數,過濾重複 cat access log grep 20 oct 2008 awk sort uniq c sort nr 4,當天...

Apache日誌分析指令碼

1,檢視apache程序 2,檢視80埠的tcp連線 netstat tan grep established grep 80 wc l 3,通過日誌檢視當天ip連線數,過濾重複 cat access log grep 20 oct 2008 awk sort uniq c sort nr 4,當天...