久々にawstatsを触る機会があり、セットアップしたものの解析が動作しない。
特定のプラグインを有効化していたが、その動作に必要なperlモジュールをインストールし忘れていただけ、というオチだった(´・ω・`)
環境
AlmaLinux release 8.9 (Midnight Oncilla)
症状と原因
awstasを設置したが、ログが解析されない。
何が起こっているのか調べるために、
/etc/cron.hourly/awstats に記述されているコマンドから、/dev/null への出力を無しにして手動で実行してみる。
# cat /etc/cron.hourly/awstats #!/bin/bash exec /usr/share/awstats/tools/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" >/dev/null exit 0
以下だけ実行。
# exec /usr/share/awstats/tools/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl"
次のようなエラーが出た。
Error: Plugin load for plugin 'geoipfree' failed with return code: Error: Can't locate Geo/IPfree.pm in @INC (you may need to install the Geo::IPfree module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 /usr/share/awstats/lib /usr/share/awstats/plugins /usr/share/awstats/wwwroot/cgi-bin/plugins) at (eval 2) line 1.
aestatsのconfファイルにて、
LoadPlugin="geoipfree"
の行を有効化しているにもかかわらず、そのプラグインを動作するためのGeo/IPfree.pmが無いらしい。
解決法
cpanからGeo::IPfreeをインストール。
cpan> install Geo::IPfree
これでログが解析されるようになる。
但し、パッケージ同梱の国判定DBは古く、定義を更新しなければ精度が良くならない。
DB定義を更新する geoipupdate パッケージをインストールしても、ライセンスを投入しなければ定義ファイルが更新されないので注意。
ライセンスは、maxmind へユーザ登録して入手する必要あり。
MaxMind / Updating GeoIP and GeoLite Databases
Updating GeoIP and GeoLite Databases | MaxMind Developer Portal