在apachelog中找出訪問次數(shù)最多的10個(gè)IP
awk '{print $1}' /usr/local/apache2/logs/access_log |sort|uniq -c|head -n 10
在apache日志中找出訪問次數(shù)最多的幾個(gè)分鐘
awk '{print $4}' /usr/local/apache2/logs/access_log|cut -c 14-18 |sort|uniq -c|sort -nr|head
在apache日志中找到訪問最多的頁面
awk '{print $7}' /usr/local/apache2/logs/access_log |sort|uniq -c|sort -nr|head
在apache日志中找出訪問次數(shù)最多(負(fù)載最重)的幾個(gè)時(shí)間段(以分鐘為單位),然后在看看這些時(shí)間哪幾個(gè)IP訪問的最多?
awk '{print $4}' /usr/local/apache2/logs/access_log |cut -c 9-18 |uniq -c|sort -nr|head
apache相關(guān)的系統(tǒng)操作
1,查看apache進(jìn)程:
ps aux | grep httpd | grep -v grep | wc -l
2,查看80端口的tcp連接:
netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l
3,通過日志查看當(dāng)天ip連接數(shù),過濾重復(fù):
cat access_log | grep "19/May/2011" | awk '{print $2}' | sort | uniq -c | sort -nr
4,當(dāng)天ip連接數(shù)最高的ip都在干些什么(原來是蜘蛛):
cat access_log | grep "19/May/2011:00" | grep "61.135.166.230" | awk '{print $8}' | sort | uniq -c | sort -nr | head -n 10
5,當(dāng)天訪問頁面排前10的url:
cat access_log | grep "19/May/2010:00" | awk '{print $8}' | sort | uniq -c | sort -nr | head -n 10
6,用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 220.181.38.183| awk '{print $1"/t"$8}' | sort | uniq -c | sort -nr | less
7,查看某一時(shí)間段的ip連接數(shù):
grep "2006:0[7-8]" www20110519.log | awk '{print $2}' | sort | uniq -c| sort -nr | wc -l
8,當(dāng)前WEB服務(wù)器中聯(lián)接次數(shù)最多的20條ip地址:
netstat -ntu |awk '{print $5}' |sort | uniq -c| sort -n -r | head -n 20
9,查看日志中訪問次數(shù)最多的前10個(gè)IP
cat access_log |cut -d ' ' -f 1 |sort |uniq -c | sort -nr | awk '{print $0 }' | head -n 10 |less
10,查看日志中出現(xiàn)100次以上的IP
cat access_log |cut -d ' ' -f 1 |sort |uniq -c | awk '{if ($1 > 100) print $0}'|sort -nr |less
11,查看最近訪問量最高的文件
cat access_log |tail -10000|awk '{print $7}'|sort|uniq -c|sort -nr|less
12,查看日志中訪問超過100次的頁面
cat access_log | cut -d ' ' -f 7 | sort |uniq -c | awk '{if ($1 > 100) print $0}' | less
13,列出傳輸時(shí)間超過 30 秒的文件
cat access_log|awk '($NF > 30){print $7}'|sort -n|uniq -c|sort -nr|head -20
14,列出最最耗時(shí)的頁面(超過60秒的)的以及對(duì)應(yīng)頁面發(fā)生次數(shù)
cat access_log |awk '($NF > 60 && $7~//.php/){print $7}'|sort -n|uniq -c|sort -nr|head -100