1 | 1 | simandl | package HotSaNICmod::OSdep; |
2 | | | |
3 | | | use lib "../../lib"; |
4 | | | |
5 | | | sub version { |
6 | | | ($VERSION = '$Revision: 1.5 $') =~ s/.*(\d+\.\d+).*/$1/; |
7 | | | return "default.pm $VERSION"; |
8 | | | } |
9 | | | |
10 | | | sub sample { |
11 | | | my %args=@_; |
12 | | | my $time; |
13 | | | |
14 | | | my $VAR=$args{VARDIR}; |
15 | | | undef my %stats; |
16 | | | |
17 | | | # kick bind to produce stats, then wait a bit for the stats file to be written. |
18 | | | system "$args{BINDPATH} stats > /dev/null"; |
19 | | | |
20 | | | # wait a bit for the stats-file to be written |
21 | | | sleep 1; |
22 | | | |
23 | | | open STATFILE, $args{BINDSTAT} or die "cannot open $args{BINDSTAT}: $!"; |
24 | | | |
25 | | | # read stats into %stats |
26 | | | while(<STATFILE>){ |
27 | | | chomp; |
28 | | | if(/\+\+\+ Statistics Dump \+\+\+ \((\d+)\)/) { $time = $1; } |
29 | | | elsif(/\-\-\- Statistics Dump/) { last; } |
30 | | | else { |
31 | | | my ($statskey, $statsval) = split; |
32 | | | $stats{$statskey} = $statsval; |
33 | | | } |
34 | | | #ignore EOF - bind may not have finished outputting stats |
35 | | | #so we'll keep reading until we get the --- line |
36 | | | while(eof STATFILE){seek STATFILE, 0, 1} |
37 | | | } |
38 | | | |
39 | | | close STATFILE; |
40 | | | |
41 | | | # remove stats file |
42 | | | unlink $args{BINDSTAT}; |
43 | | | |
44 | | | # insert values into rrd |
45 | | | HotSaNICmod::do_rrd("bind","U",$time,$stats{success},$stats{referral},$stats{nxrrset},$stats{nxdomain},$stats{recursion},$stats{failure}); |
46 | | | } |
47 | | | |
48 | | | 1; |
49 | | | |