awstats workaround for custom delimiter tab methodurl bug

For some sites i am using the venerable awstats to keep track of web site statistics; and came across a problem today:

If your apache LogFormat is using a \t (tab) to separate fields you may notice how awstats does not parse %methodurl correctly – instead it looks like your two top pages are called HTTP/1.0 and HTTP/1.1. Read more for a workaround.

So after an hour of looking i found that this behaviour is a documented bug (should have checked that first!). Since i was unable to produce an immediate fix, i came up with this workaround, so you can leave your httpd.conf’s LogFormat the way it is and still use awstats to produce functioning reports:

Create a new document called /usr/local/bin/awstats_workaround.pl with the following contents:

#!/usr/bin/perl
 
use strict;
use warnings;
 
die("Need Logfile as input!!!\n") unless (@ARGV);
 
while(<>){
	s/\t/ /g;
	print;
}

Now in your relevant awstats.conf file, make sure you have the following 2 entries:

LogFile="/usr/local/bin/awstats_workaround.pl /var/log/httpd-access.log |"
LogSeparator=" "

Now create your awstats report as usual. Awstats gets its input from /usr/local/bin/awstats_workaround.pl, which replaces all those \t characters with a regular old space. Hope this quick workaround helps you until this custom delimiter bug is fixed in the awstats code – people are aware of it but so far versions up until 7.1 are not fixed yet

Speak Your Mind

*