#!/usr/bin/env perl
do "common.pl";

%bandwidth;

open(FILE,$file);
while(<FILE>) {
    /\S*\ \S*\ \S*\ \S*\ \S*\ \S*\ (\S*)\ \S*\ \S*\ (\S*)/;
    $url = $1;
    $size= $2;
    if ( $size eq "-" ) { $size = 0 };
    $bandwidth{$url} =+ $size;

}
close(FILE);

$total;
@tmp;
@toplisting;

foreach $url (sort { $bandwidth{$b} <=> $bandwidth{$a}; } keys %bandwidth) {
    push(@toplisting, $url);
    $total = $total + $bandwidth{$url};
# Manual search remaining agents
#    else {
#        print $agent;
#    }
}

print "Total Bandwidth (bytes): $total\n";
print "top 10 bandwidth\n";
foreach $i (0 .. 9 ) {
    print $i + 1, ": $toplisting[$i] \[$bandwidth{$toplisting[$i]} ",
    percent($bandwidth{$toplisting[$i]},$total) ,"\]\n";
}
exit(0);
