hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
package HotSaNICmod::OSdep;
use lib "../../lib";
sub version {
($VERSION = '$Revision: 1.5 $') =~ s/.*(\d+\.\d+).*/$1/;
return "default.pm $VERSION";
}
sub sample {
my %args=@_;
my $time;
my $VAR=$args{VARDIR};
undef my %stats;
# kick bind to produce stats, then wait a bit for the stats file to be written.
system "$args{BINDPATH} stats > /dev/null";
# wait a bit for the stats-file to be written
sleep 1;
open STATFILE, $args{BINDSTAT} or die "cannot open $args{BINDSTAT}: $!";
# read stats into %stats
while(<STATFILE>){
chomp;
if(/\+\+\+ Statistics Dump \+\+\+ \((\d+)\)/) { $time = $1; }
elsif(/\-\-\- Statistics Dump/) { last; }
else {
my ($statskey, $statsval) = split;
$stats{$statskey} = $statsval;
}
#ignore EOF - bind may not have finished outputting stats
#so we'll keep reading until we get the --- line
while(eof STATFILE){seek STATFILE, 0, 1}
}
close STATFILE;
# remove stats file
unlink $args{BINDSTAT};
# insert values into rrd
HotSaNICmod::do_rrd("bind","U",$time,$stats{success},$stats{referral},$stats{nxrrset},$stats{nxdomain},$stats{recursion},$stats{failure});
}
1;