/[cricket]/parse_bind9stat.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /parse_bind9stat.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by dpavlin, Mon Jul 1 20:01:25 2002 UTC revision 1.5 by dpavlin, Wed Jul 10 22:41:01 2002 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  my $bind9_dump = shift @ARGV || "/var/log/stats.dump";  my $log = shift @ARGV || "/var/log/stats.dump";
6  my $rndc = shift @ARGV || "/usr/sbin/rndc";  my $rndc = shift @ARGV || "/usr/sbin/rndc";
7    my $delta="/var/tmp/";
8    
9  system "$rndc stats";  system "$rndc stats";
10    
# Line 13  my %total; Line 14  my %total;
14  my %forward;  my %forward;
15  my %reverse;  my %reverse;
16    
17  open(D,$bind9_dump) || die "$bind9_dump: $!";  my $tmp=$log;
18  while(<D>) {  $tmp=~s/\W/_/g;
19    $delta.=$tmp.".offset";
20    
21    open(DUMP,$log) || die "$log: $!";
22    
23    if (-e $delta) {
24            open(D,$delta) || die "can't open delta file '$delta' for '$log': $!";
25            my $offset=<D>;
26            chomp $offset;
27            close(D);
28            my $log_size = -s $log;
29            if ($offset <= $log_size) {
30                    seek(DUMP,$offset,0);
31            }
32    }
33    
34    while(<DUMP>) {
35          next if /^(---|\+\+\+)/;          next if /^(---|\+\+\+)/;
36          chomp;          chomp;
37          my ($what,$nr,$direction) = split(/\s+/,$_,3);          my ($what,$nr,$direction) = split(/\s+/,$_,3);
# Line 27  while(<D>) { Line 44  while(<D>) {
44          }          }
45    
46  }  }
47    close(DUMP);
48    
49    open(D,"> $delta") || die "can't open delta file '$delta' for log '$log': $!";
50    print D tell(DUMP);
51  close(D);  close(D);
52    
53  foreach (@counters) {  foreach (@counters) {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.26