... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2004-05-25

awstats

I was using awstats to analyze IIS server logs.  It requires Perl.  At first I was using Perl installed under CygWin, but I found that it did not handle newlines properly.  So I switched to ActiveState.  That worked.  I found out that the default IIS log format is a bit damaged.  It is missing two key pieces of information that awstats needs:  date(!) and bytes transferred.  I wrote a Perl script that adds the correct date to the beginning of each log line (extracting it from comments in the log) and adds a zero as a dummy byte count:

my $date = "<unknown>";
foreach (<>)
{
    if (/^#Date: ([^ ]*)/) { $date = $1; print $_; }
    elsif (/^#/) { print $_; }
    else { chomp; print $date . " " . $_ . " 0\n"; }
}

This made it possible for awstats to perform its analysis.  awstats is a bit finicky about configuration.  In the wwwroot/cgi-bin of the distribution, I created a configuration file named (for example), awstats.nemesis.conf (where nemesis is the host name).  I changed:

  • LogFile to point to the log file to analyze
  • LogFormat to "date time c-ip cs-method cs-uri-stem sc-status %bytesd"
  • SiteDomain to nemesis.
  • DirData to ../data.
  • DirIcons to <distribution directory>/wwwroot/icon

Then, I created the statistics by running this command in the cgi-bin directory:

awstats.pl -config=nemesis -update

Finally, I created the web pages with the command:

..\..\tools\awstats_buildstaticpages.pl
    -config=nemesis ^
    -dir=h:\desktop\zot

I had to copy the configuration file into ..\..\tools for this to work.  Also, the output directory had to exist.

All-in-all, I wasn't that impressed with the reports generated.

Blog Archive