83
88

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ログ解析のとき便利なコマンドまとめ

Last updated at Posted at 2014-09-09

特定のIPアドレスからのアクセスを抽出する

grep "^188.92.76.167" access_log-20140907 

or

cat access_log-20140907 | grep "^188.92.76.167"

特定のIPアドレスからのアクセスを抽出し CSS やらへのアクセスを除外する

grep "^188.92.76.167" access_log-20140907 | grep -ive "GET /.*\.\(css\|js\|jpg\|gif\|png\|swf\|ico\)\ HTTP"

特定のIPアドレスからのアクセスを抽出し CSS やらへのアクセスを除外し、さらにリアルタイムに監視する

tail -f access_log-20140907 | grep "^188.92.76.167" | grep -ive "GET /.*\.\(css\|js\|jpg\|gif\|png\|swf\|ico\)\ HTTP"

特定ファイルへのアクセス数を抽出する

$ cat /var/log/httpd/access.log | grep favicon.ico | wc -l

特定のIPアドレスからのアクセスを抽出し CSS やらへのアクセスを除外し、さらにはbotも除外する

grep "^188.92.76.167" access_log-20140907 | grep -ive "GET /.*\.\(css\|js\|jpg\|gif\|png\|swf\|ico\|Baiduspider|server-status|Ask Jeeves|Yeti|Yahoo!Slurp|Mediapartners-Google|Googlebot|Plagger|Twiceler|Y!J-BSC|Feedfetcher-Google|AMZNKAssocBot|livedoor HttpClient|Fastladder FeedFetche|FreshReader)\ HTTP"

今回はgrep, cut, awk, sort, uniq, wc などを利用した。
各コマンドの詳細については以下を参考にした。

参考

バシャログ tnakamuraさんとても参考になりました。

83
88
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
83
88

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?