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
ログの量にも依りますが、相応に重い処理になります。サーバ運用機上では、実行しないほうがいいかも…
入力ファイルと出力先を設定します。既に、週毎のログ集計設定がされているので、バックアップをしておきます。
# 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
これで完成。