9 my $gi = Geo::IP->open("/usr/share/GeoIP/GeoIP.dat", GEOIP_MEMORY_CACHE);
13 while (my $record = <>)
15 if ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+TCP_[A-Z_]+\/\d+\s+(\d+) (?:GET|HEAD|POST|OPTIONS|PROPFIND) /)
19 my $country = $gi->country_code_by_addr($ip);
21 if (defined($country) &&
22 $country ne "A1" && $country ne "A2" &&
23 $country ne "01" && $country ne "--")
25 $country_bytes{$country} += $bytes;
28 $total_bytes += $bytes;
30 elsif ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+TCP_DENIED\/\d+\s+(\d+) /)
34 elsif ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+UDP_[A-Z_]+\/\d+\s+(\d+) ICP_QUERY /)
44 my %country_bandwidth;
46 while (my($country,$bytes) = each %country_bytes)
48 $country_bandwidth{$country} = $bytes * 300 * 1024 * 1024 / $total_bytes;
51 print Dump(\%country_bandwidth);