9 my $gi = Geo::IP->open("/usr/share/GeoIP/GeoIP.dat", GEOIP_MEMORY_CACHE);
10 my $total_bandwidth = 560 * 1024 * 1024;
14 while (my $record = <>)
16 if ($record =~ /^\d+\.\d+\s+\S+\s+".*"\s+(\d+\.\d+\.\d+\.\d+)\s+".*"\s+(\d+)$/)
20 my $country = $gi->country_code_by_addr($ip);
22 if (defined($country) &&
23 $country ne "A1" && $country ne "A2" &&
24 $country ne "01" && $country ne "--")
26 $country_bytes{$country} += $bytes;
29 $total_bytes += $bytes;
37 my %country_bandwidth;
39 while (my($country,$bytes) = each %country_bytes)
41 $country_bandwidth{$country} = $bytes * $total_bandwidth / $total_bytes;
44 print Dump(\%country_bandwidth);