plugins/check_dns-serial
changeset 8 a220ea51b60b
parent 7 f027886d3617
child 9 b2a26d05b063
equal deleted inserted replaced
7:f027886d3617 8:a220ea51b60b
   131 # CRITICAL - if the serial cannot be found at one of the sources
   131 # CRITICAL - if the serial cannot be found at one of the sources
   132 
   132 
   133 sub ns_ok {
   133 sub ns_ok {
   134     my ($domain, $reference) = @_;
   134     my ($domain, $reference) = @_;
   135 
   135 
   136     my @our = sort +ns($domain, nameservers => [$reference], aa => 1);
   136     my @errs;
   137     my @their = sort +ns($domain);
   137     my @our = eval { sort +ns($domain, nameservers => [$reference], aa => 1) };
   138 
   138     push @errs, $@ if $@;
   139     {
   139     my @their = eval { sort +ns($domain) };
   140         local $" = "\0";
   140     push @errs, $@ if $@;
   141         return 1 if "@our" eq "@their";
   141 
   142     }
   142     if (!@errs) {
   143 
   143         local $" = ', ';
   144     local $" = ', ';
   144 	if ("@our" eq "@their") {
   145     die "NS differ (our @our) vs (their @their)\n";
   145 		return 1;
       
   146 	}
       
   147         die "NS differ (our @our) vs (their @their)\n";
       
   148     }
       
   149     chomp @errs;
       
   150     die join(', ', @errs) . "\n";
       
   151 
   146 }
   152 }
   147 
   153 
   148 sub main {
   154 sub main {
   149     my @argv          = @_;
   155     my @argv          = @_;
   150     my $opt_reference = '127.0.0.1';
   156     my $opt_reference = '127.0.0.1';
   169 
   175 
   170     my (@OK, %CRITICAL);
   176     my (@OK, %CRITICAL);
   171     foreach my $domain (@domains) {
   177     foreach my $domain (@domains) {
   172         print STDERR "$domain " if $opt_progress;
   178         print STDERR "$domain " if $opt_progress;
   173         eval { ns_ok($domain, $opt_reference) };
   179         eval { ns_ok($domain, $opt_reference) };
   174         if ($@) { $CRITICAL{$domain} = $@ }
   180 	if ($@) { $CRITICAL{$domain} = $@ }
   175         else    { push @OK, $domain }
   181         else { push @OK, $domain }
   176         say STDERR $@ ? 'not ok' : 'ok' if $opt_progress;
   182         say STDERR $@ ? 'not ok' : 'ok' if $opt_progress;
   177     }
   183     }
   178 
   184 
   179     #    use DDP;
   185     #    use DDP;
   180     #    p @OK;
   186     #    p @OK;