Awstats

Awstats

apt-get install awstats

copy configuration files and cached data (old statistics) from old machine (the
cached data will have to be copied once again exactly before moving to
production)

mkdir /var/cache/awstats
ln -s /usr/share/doc/awstats/examples/awstats_buildstaticpages.pl
apt-get install libgeo-ipfree-perl libgeo-ip-perl geoip-bin
#(required for the geoip plugin for awstats)

Build the stats files using:

AWSTATS=/usr/lib/cgi-bin/awstats.pl
$AWSTATS -config=nemesisit.ro -update
awstats_buildstaticpages.pl -config=nemesisit.ro -dir=/data/www/data/analyze/awstats -awstatsprog=$AWSTATS

Not so simple

At first everything seemed ok and I was even dumb enough to not check the results in detail but after a while I realized they did not worked:

Error Opening file GeoIP.dat....Can't call method "country_code_by_addr" on an undefined value at /usr/share/awstats/plugins/geoip.pm line 96, <LOG> line 2.

I decided to do a small program of my own to check

#!/usr/bin/perl

use Geo::IP;
my $gi = Geo::IP->open(“/usr/share/GeoIP/GeoIP.dat”, GEOIP_STANDARD);
print $gi->country_code_by_addr(“82.76.38.145”);

This worked so finally I modified the /usr/share/awstats/plugins/geoip.pm file:

diff geoip.pm geoip.pm.orig
63c63<      
if (! $datafile) { $datafile="/usr/share/GeoIP/GeoIP.dat"; }
--->      
if (! $datafile) { $datafile="GeoIP.dat"; }

One Response

  1. Maybe you didn’t load the geoip plugin with the correct 2 parameters (mode and path to GeoIP.dat). See the description of the GeoIP plugin at http://awstats.sourceforge.net/docs/awstats_contrib.html

Leave a Reply

*