AWStatsで過去のログから統計を再計算する / How to recalculate AWStats statistics

  • 投稿日:
  • 更新日:2015/02/28
  • by
  • カテゴリ:

(English below)

前回サーチフレーズが出なくなっていたAWStatsを修正したのですが、過去のログについてはそのままでした。 今回はそれを直します。

1. サーチフレーズが出ないレポートファイルをバックアップする(移動する)

AWStatsの統計情報が入っているディレクトリawstats.conf内の"DirData"で設定してあります)に移動し、サーチフレーズが出ない月の統計情報ファイルをどこかに移動しておきます(削除してもいいですが、この後の処理に失敗すると元に戻せなくなります)。

% cd (DirData)
% mkdir backup
(2013年のファイルをバックアップする場合。ファイル名はawstats.confの設定により異なります)
% mv awstats??2013.www.example.com.txt backup

2. ログファイルを用意する

過去のaccess_logファイルをすべてつなげたものを用意します。 ファイルがたくさんある場合、再計算したい時期のログのみ結合すれば十分です。

% cd (cgi-bin/awstats)
% cat /var/log/access_log* > log
(ログが圧縮してある場合、catの代わりにAWStats付属のlogresolvemerge.plを使う方法もあります)

3. 再計算する

awstats.plを使って再計算を行います。

% ./awstats.pl -config=awstats.conf -update -logfile=log

私の場合、処理対象のログはおよそ1GBほどあり、処理にはかなりの時間がかかりましたが、一晩ほっておいたら終了していました。

(最後に飛ぶ)

I have fixed AWStats that didn't show search phrases, but it didn't work for the past log. Now I'll fix it.

1. Back up /move report files that didn't show search phrases

Move to the directory that contains AWStats statistics (you can find it in "DirData" variable in awstats.conf), move statistic files to somewhere. You can delete them instead, but in this case you cannot undo it if you don't succeed.

% cd (DirData)
% mkdir backup
(E.g. back up files on 2013, file names differ based on the settings in awstats.conf)
% mv awstats??2013.www.example.com.txt backup

2. Prepare log files

Concatinate all the past log files. What you need is the log files containing log periods to recalculate.

% cd (cgi-bin/awstats)
% cat /var/log/access_log* > log
(If your logs are compressed, you can use logresolvemerge.pl in AWStats distribution instead of cat)

3. Recalculate

Use awstats.pl as usual.

% ./awstats.pl -config=awstats.conf -update -logfile=log

In my case the log volume to prosess was around 1GB. It took quite a while but I just left it a night and it was all done in the next morning.

こちらもよく読まれています