Taylor Barstow - 2008-06-05


I just started using awstats, and I needed a way to incorporate the information provided by mod_logio for Apache. Looking around the forums I found some similar requests from a while back.

mod_logio adds two log format variables to Apache: %I (for the total number of bytes input, including headers) and %O (for the total number of bytes output).

I didn't want to make any intrusive hacks, like adding another column to the report or anything. I really just wanted to have the bandwidth column show me the sum of %I and %O.

So I added a few lines to awstats.pl which allow me to add a new variable, %bytesi, to LogFormat. When %bytesi is present, my version of awstats.pl will add this value to %bytesd for each line that is parsed. This seems like a reasonable implementation, since it is "opt-in" (it only kicks in if you use %bytesi), making it completely backwards compatible.

Please see my patch below. Is there any chance of getting this included in a future release?

Taylor Barstow

< $pos_vh $pos_host $pos_logname $pos_date $pos_tz $pos_method $pos_url $pos_code $pos_size

> $pos_vh $pos_host $pos_logname $pos_date $pos_tz $pos_method $pos_url $pos_code $pos_size $pos_sizein
< $pos_vh = $pos_host = $pos_logname = $pos_date = $pos_tz = $pos_method = $pos_url = $pos_code = $pos_size = -1;

> $pos_vh = $pos_host = $pos_logname = $pos_date = $pos_tz = $pos_method = $pos_url = $pos_code = $pos_size = $pos_sizein = -1;
> elsif ($f =~ /%bytesi$/) {
> $pos_sizein = $i; $i++; push @fieldlib, 'sizein';
> $PerlParsingFormat .= "([^$LogSeparatorWithoutStar]+)";
> }
> if ($pos_sizein >= 0) {
> $field[$pos_size] += $field[$pos_sizein];
> }