1 |
dpavlin |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
|
5 |
dpavlin |
1.2 |
my $bind9_dump = shift @_ || "/var/log/named/stats.dump"; |
6 |
|
|
my $rndc = shift @_ || "/usr/local/sbin/rndc"; |
7 |
dpavlin |
1.1 |
|
8 |
dpavlin |
1.2 |
system "$rndc stats"; |
9 |
dpavlin |
1.1 |
|
10 |
|
|
my @counters = qw(success referral nxrrset nxdomain recursion failure); |
11 |
|
|
|
12 |
|
|
my %total; |
13 |
|
|
my %forward; |
14 |
|
|
my %reverse; |
15 |
|
|
|
16 |
|
|
open(D,$bind9_dump) || die "$bind9_dump: $!"; |
17 |
|
|
while(<D>) { |
18 |
|
|
next if /^(---|\+\+\+)/; |
19 |
|
|
chomp; |
20 |
|
|
my ($what,$nr,$direction) = split(/\s+/,$_,3); |
21 |
|
|
if (! $direction) { |
22 |
|
|
$total{$what} += $nr; |
23 |
|
|
} elsif ($direction =~ m/in-addr.arpa/) { |
24 |
|
|
$reverse{$what} += $nr; |
25 |
|
|
} else { |
26 |
|
|
$forward{$what} += $nr; |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
} |
30 |
|
|
close(D); |
31 |
|
|
|
32 |
|
|
foreach (@counters) { |
33 |
|
|
print $total{$_},"\n",$forward{$_},"\n",$reverse{$_},"\n"; |
34 |
|
|
} |