#! /usr/bin/perl

my (%count, %bytes);
our (@f, $key);

sub make_pass(&) {
	my $processor = shift;

	while ($_ = <STDIN>) {
		@f = split;
		next if $f[8] ne '200' && $f[8] ne '"200"';

		$key = "$f[5] $f[6]";
		$processor->();
	}

	seek STDIN, 0, 0 or die; # rewind, die if not seekable
}

make_pass {
	++$count{$key};
	$bytes{$key} += $f[9];
};

my $bot_chunk = 16384;
make_pass {
	next if $count{$key} < 10; # epsilon for uniqueness

	next if $f[9] == 0;	# no bytes transfered, interesting but separate thing

	my $avg = $bytes{$key} / $count{$key};
	if ($f[9] < $bot_chunk && $f[9] < $avg/10) {
		print qq{"*** too small: $f[9] vs. avg $avg" $_};
	}
};
