#!/usr/bin/perl # # Break down the bytes of this access.log. my %uri_bytes; my $bytes_total; while (defined (my $line = )) { # For PEx, the pid is included. my ($pid, $host, $rfc931, $authuser, $timestamp, $request, $status, $bytes) = ($line =~ /^(\d+) (\S+) (\S+) (\S+) \[([^\]]*)\] \"([^\"]*)\" (\S+) (\S+)/); my ($uri) = ($request =~ /^GET\s(.*?)\s/); if ($uri) { my $s; # xxx Suboptimal! if ($uri =~ /\?/) { ($s) = ($uri =~ /^(.*?)\?/); } else { $s = $uri; } $uri_bytes{$s} += $bytes; $bytes_total += $bytes; } } my @a; foreach my $k (keys (%uri_bytes)) { push (@a, [$k, $uri_bytes{$k}]); } @a = sort {-($a->[1] <=> $b->[1])} @a; foreach my $e (@a) { printf "%12d %3d %s\n", $e->[1], $e->[1] * 1000 / $bytes_total, $e->[0]; }