2009-02-25から1日間の記事一覧

ホストごとの集計

sh

$ sudo cat /var/log/apache2/access.log | grep -v 127.0.0.1 | grep -v 192.168. | cut -d" " -f1 | sort | xargs -n 1 host | cut -d" " -f5-6 | sort |uniq -c

ipごとの集計

sh

$ sudo cat /var/log/apache2/access.log | grep -v 127.0.0.1 | grep -v 192.168. | cut -d" " -f1 | sort | uniq -c

一行でできた。

sh

やっぱしこういうときはxargsだった。xargsがhostに渡す引数の個数の指定を追加、オプション修正。 $ sudo cat /var/log/apache2/access.log | grep -v 127.0.0.1 | grep -v 192.168. | cut -d" " -f1 | sort -u | xargs -n 1 host | cut -d" " -f5-6 > acce…

apacheのaccess.logからipの逆引き

$ sudo cat /var/log/apache2/access.log | grep -v 127.0.0.1 | grep -v 192.168. | cut -d" " -f1 | sort | uniq > access_ip.txt $ while read line do host $line done < access_ip.txt | cut -d" " -f5 > access_host.txt 各行に対してhostコマンドした…

ホストごとの集計2

sh

sedのおまけつき。シングルクオート内なら()と|をエスケープしなくてもいいと思ってたんだけどエスケープ必要っぽい。 http://merry.whitesnow.jp/SEMICMD/SECTION6/section6_1.html $ sudo cat /var/log/apache2/access.log | grep -v 127.0.0.1 | grep -v …