X-Git-Url: https://git.openstreetmap.org/dns.git/blobdiff_plain/f054b3702b5d3ac235c9259233244f7c4933cb5c..9499aa23156007dacac1b5a8faea2ea97fccfe3c:/bin/sumlogs diff --git a/bin/sumlogs b/bin/sumlogs index 0db3ac6..400a363 100755 --- a/bin/sumlogs +++ b/bin/sumlogs @@ -8,7 +8,7 @@ use YAML; my $pt = new Net::Patricia; -open(COUNTRIES, "< /etc/powerdns/countries.conf") || die "Can't open /etc/powerdns/countries.conf"; +open(COUNTRIES, "< countries.conf") || die "Can't open /etc/powerdns/countries.conf"; while (my $line = ) { @@ -28,7 +28,7 @@ my %country_bytes; while (my $record = <>) { - if ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+TCP_[A-Z_]+\/\d+\s+(\d+) /) + if ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+TCP_[A-Z_]+\/\d+\s+(\d+) (?:GET|HEAD|POST) /) { my $ip = $1; my $bytes = $2; @@ -38,6 +38,10 @@ while (my $record = <>) $total_bytes += $bytes; } + elsif ($record =~ /^\d+\.\d+\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+UDP_[A-Z_]+\/\d+\s+(\d+) ICP_QUERY /) + { + # do nothing + } else { warn $record; @@ -48,7 +52,7 @@ my %country_bandwidth; while (my($country,$bytes) = each %country_bytes) { - $country_bandwidth{$country} = $bytes * 250 * 1024 * 1024 / $total_bytes; + $country_bandwidth{$country} = $bytes * 300 * 1024 * 1024 / $total_bytes; } print Dump(\%country_bandwidth);