Analogで半年分を解析

Analog で、半年分の Apacheログを解析したいと思います。うちの場合、logrotateにより、ログが一週間単位に分割されているので、まずそれらの結合から始まります。

結合用のシェル

適当に新しくディレクトリを作り、そこへ結合対象のログファイル群をコピーします。下記のように正規表現を使うと、効率が良いと思います。

$ cp /etc/httpd/logs/access_log.[1-5][0-9] ./

そして、以下のシェルを走らせます。

#!/bin/bash

# 絶対に、"^access_log*"としては駄目。
# 結合対象に、集計ファイル自身も入ってしまうため
output_file=all_access_log

if [ -e ${output_file} ];
then
  rm ${output_file}
fi

touch ${output_file}

for name in access_log*
do
  cp -f ${output_file} ${output_file}.tmp
  cat ${output_file}.tmp $name > ${output_file}
done

rm ${output_file}.tmp

ログの量にも依りますが、相応に重い処理になります。サーバ運用機上では、実行しないほうがいいかも…

analog.cfgの修正

入力ファイルと出力先を設定します。既に、週毎のログ集計設定がされているので、バックアップをしておきます。

# cd /usr/local/etc
# cp analog.cfg analog.cfg.bak

解析実行

解析を実行します。出力ファイル名を all_access_log_result.html とし、変換後のファイル名を all_access_log_result_ja.html とします。

# analog
# analogurldecode all_access_log_result.html >all_access_log_result_ja.html

これで完成。


履歴


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-01-29 (火) 07:23:45