apacheなどの、アクセスログ集計ツール
CentOSでは、yumによるインストールを行うことが可能
yumによるインストール
yum install awstats
インストールされるディレクトリ
/usr/share/awstats/
コンフィグファイルを生成する
コンフィグファイルを作成するツールは、
/usr/share/awstats/tools/awstats_configure.pl
現時点では、作成手順を割愛しちゃうん
質問される項目
-----> Running OS detected: Linux, BSD or Unix
-----> Check for web server install
Found Web server Apache config file '/usr/local/apache2/conf/httpd.conf'
ここで、Apache の conf ファイルの場所を指定します
自動的に認識された場合、入力はスキップされます
-----> Check and complete web server config file '/usr/local/apache2/conf/httpd.conf'
All AWStats directives are already present.
-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?y コンフィグファイルを作成するか聞いてくる
-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.websv02 コンフィグファイル名(サーバ名)を入力する
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
> 規定ディレクトリ /etc/awstats に作成して良い場合、何も入力せすEnter
-----> Create config file '/etc/awstats/awstats.www.websv02.conf'
Config file /etc/awstats/awstats.www.websv02.conf created.
-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.websv02
Or if you have several config files and prefer having only one command:
/usr/share/awstats/tools/awstats_updateall.pl now
Press ENTER to continue... こんなファイルをこんなディレクトリに作成したよ! と表示される確認してEnter
A SIMPLE config file has been created: /etc/awstats/awstats.www.websv02.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.websv02' with command:
> perl awstats.pl -update -config=www.websv02
You can also read your statistics for 'www.websv02' with URL:
> http://localhost/awstats/awstats.pl?config=www.websv02
Press ENTER to finish...
データの更新方法と、ウェブのアクセス方法を表示して終了します。
集計を行う場合
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=コンフィグファイル名
通常は、シェルスクリプトを作成して、夜中にcronde実行させたりするのが一般的ではなかろうか?
/usr/share/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.websv02
集計したawstatsをアクセスする場合
http://サーバ名/awstats/awstats.pl?config=コンフィグファイル名
awstatsの集計結果が保存される場所/集計結果をリセットする
/var/lib/awstats/
ここにある、コンフィグファイル名と同じ名称のファイル(.txtの拡張子がついていた)を削除して
再度集計を行うと、新たに集計結果を作成してくれる。
※ここにあるファイルを削除しないと、過去に集計した結果はいつまでも残ります。
awstatsの設定ファイルは、/etc/awstats/に作成される
各種設定パラメータの説明
特定のIPアドレスを集計させないようにする
規定値は、自分自身からのアクセスを集計させないようにしていた。
死活監視などで、頻繁にアクセスログに記録される場合、死活監視をしているサーバのIPアドレスを追記すると、集計結果に反映されなくなる。
SkipHosts="127.0.0.1 REGEX[^172\.16\.]"
上記の様に記述すると、172.16で始まるIPアドレスからのアクセスを集計対象外とする。