use strict;
my %agent;
my %action;
my %bandwidth;
my $actions;
my $hits;
my $bandwidth;
my $bot_bandwidth;
my $bot_hits;
while (<STDIN>) {
  my ($action, $code, $bytes, $referrer, $agent)
   = m/"(.*?)" (\d+) (\d+|-) .*?"(.*?)".*?"(.*?)"/ or die "Cannot parse:\n$_";
  $bandwidth += $bytes;
  next unless $agent =~ /([a-z]*bot[a-z]*)/i;
  $agent =~ /http:\/\/([^ \/]+)/;
  my $key = $1 || 'no url';
  $bandwidth{$key} += $bytes;
  $bot_bandwidth += $bytes;
  if ($action =~ /action=/i) {
my @result = sort {$agent{$b} <=> $agent{$a}} keys %agent;

print "    ----------------------------Bandwidth-------Hits-------Actions\n";
printf "%30s %9dM %10d\n", 'Everybody',
  $bandwidth / 1024 / 1024, $hits;
printf "%30s %9dM %10d   %3d%%   %3d%%\n", 'All Bots',
  $bot_bandwidth / 1024 / 1024, $bot_hits, 100, 100 * $actions / $bot_hits;
print "    --------------------------------------------------------------\n";
foreach my $key (@result) {
  printf "%30s %9dK %10d   %3d%%   %3d%%\n", $key,
    $bandwidth{$key} / 1024,
    100 * $agent{$key} / $bot_hits,
    100 * $action{$key} / $agent{$key};


Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.