plugins/check_dns-delegation
changeset 11 cd4343d59850
parent 10 4243e22505f9
child 12 4b081298e09d
equal deleted inserted replaced
10:4243e22505f9 11:cd4343d59850
   153 # CRITICAL - if the serial cannot be found at one of the sources
   153 # CRITICAL - if the serial cannot be found at one of the sources
   154 
   154 
   155 sub ns_ok {
   155 sub ns_ok {
   156     my ($domain, $reference) = @_;
   156     my ($domain, $reference) = @_;
   157 
   157 
   158     my @errs;
   158     my (@errs, @ns);
   159     my @our = eval { sort +ns($domain, nameservers => [$reference], aa => 1) };
   159     my @our = eval { sort +ns($domain, nameservers => [$reference], aa => 1) };
   160     push @errs, $@ if $@;
   160     push @errs, $@ if $@;
   161     my @their = eval { sort +ns($domain) };
   161     my @their = eval { sort +ns($domain) };
   162     push @errs, $@ if $@;
   162     push @errs, $@ if $@;
   163 
   163 
   169     if ("@our" ne "@their") {
   169     if ("@our" ne "@their") {
   170         local $" = ', ';
   170         local $" = ', ';
   171         die "NS differ (our @our) vs (their @their)\n";
   171         die "NS differ (our @our) vs (their @their)\n";
   172     }
   172     }
   173 
   173 
   174     return uniq sort @our, @their;
   174     @ns = uniq sort @our, @their;
       
   175     ### @ns
       
   176     return @ns;
   175 }
   177 }
   176 
   178 
   177 sub serial_ok {
   179 sub serial_ok {
   178     my ($domain, @ns) = @_;
   180     my ($domain, @ns) = @_;
   179     my @serials = map { my $s = serial $domain, nameservers => [$_]; "$s\@$_" } @ns;
   181     my @serials = map { my $s = serial $domain, nameservers => [$_]; "$s\@$_" } @ns;
       
   182     ### @serials
   180 
   183 
   181     if (uniq(map { /(\d+)/ } @serials) != 1) {
   184     if (uniq(map { /(\d+)/ } @serials) != 1) {
   182         die "serials do not match: @serials\n";
   185         die "serials do not match: @serials\n";
   183     }
   186     }
   184     
   187     
   218             say STDERR 'ns not ok' if $opt_progress;
   221             say STDERR 'ns not ok' if $opt_progress;
   219             next;
   222             next;
   220         }
   223         }
   221         print STDERR 'ok(ns) ' if $opt_progress;
   224         print STDERR 'ok(ns) ' if $opt_progress;
   222 
   225 
   223         my @serial = eval { serial_ok($domain, @ns) };
   226         my @serial = eval { serial_ok($domain, @ns, $opt_reference) };
   224         if ($@) {
   227         if ($@) {
   225             $CRITICAL{$domain} = $@;
   228             $CRITICAL{$domain} = $@;
   226             say STDERR 'serial not ok' if $opt_progress;
   229             say STDERR 'serial not ok' if $opt_progress;
   227             next;
   230             next;
   228         }
   231         }