my $INDIR = shift;
-my $count =
- { 'ok' => [],
- 'warn' => [],
- 'critical' => [],
- 'unknown' => [],
- 'unsigned' => [],
- };
+my $states = [qw{critical warn unknown ok unsigned}];
+my $count = { map { $_ => [] } @$states };
+my $details = { map { $_ => [] } @$states };
my %dnsseczones;
next unless ( -f "$file" );
my $do_dnssec = 1;
+ my $delegated = 1;
my $initial_refs = undef;
open(F, '<', $file) or die ("Cannot open $file: $!\n");
for (<F>) {
if (/^; wzf:\s*dnssec\s*=\s*0\s*$/) { $do_dnssec = 0; }
+ if (/^; delegated\s*=\s*no\s*$/) { $delegated = 0; }
if (/^; check-initial-refs\s*=\s*(.*?)\s*$/) { $initial_refs = $1; }
};
close F;
- if ($do_dnssec) {
+ if ($do_dnssec && $delegated) {
die "Duplicate zone $file?\n" if exists $dnsseczones{$file};
$dnsseczones{$file} = {};
$dnsseczones{$file}->{'initial_refs'} = $initial_refs if defined $initial_refs;
} else {
- push @{$count->{'unsigned'}}, $file;
+ push @{$count ->{'unsigned'}}, $file;
+ push @{$details->{'unsigned'}}, "$file: marked unsigned or undelegated.\n";
};
}
closedir(INDIR);
closedir(INDIR);
}
-my @details;
-
my %threads;
for my $zone (sort {$a cmp $b} keys %dnsseczones) {
die "Duplicate zone $zone?\n" if defined $threads{$zone};
my ($res, $det) = $threads{$zone}->join();
- push @details, @$det;
+ my $type = ($res == 0) ? 'ok' :
+ ($res == 1) ? 'warn' :
+ ($res == 2) ? 'critical' :
+ 'unknown';
- if ($res == 0) { push @{$count->{'ok'}}, $zone; }
- elsif ($res == 1) { push @{$count->{'warn'}}, $zone; }
- elsif ($res == 2) { push @{$count->{'critical'}}, $zone; }
- else { push @{$count->{'unknown'}}, $zone; };
+ push @{$details->{$type}}, @$det;
+ push @{$count ->{$type}}, $zone;
delete $threads{$zone};
}
- sleep(1) unless scalar keys %threads == 0;
+ last if scalar keys %threads == 0;
+ print STDERR (scalar keys %threads), " threads left: ", join(" ", keys %threads), "\n" if $params->{'debug'};
+ sleep 1;
}
for my $zone (sort {$a cmp $b} keys %threads) {
- push @{$count->{'warn'}}, $zone;
- push @details, "$zone: timeout during check\n";
+ push @{$count ->{'warn'}}, $zone;
+ push @{$details->{'warn'}}, "$zone: timeout during check\n";
$threads{$zone}->kill('KILL')->detach();
}
-for my $k (keys %$count) {
- @{$count->{$k}} = sort {$a cmp $b} @{$count->{$k}};
-}
-
my $exit = 0;
my %state_mapping = (
'unknown' => 255,
'critical' => 2,
'warn' => 1,
+ 'unsigned' => 0,
'ok' => 0 );
-for my $state (sort {$state_mapping{$b} <=> $state_mapping{$a}} keys %state_mapping) {
+for my $state (@$states) {
+ @{$count->{$state}} = sort {$a cmp $b} @{$count->{$state}};
+ @{$details->{$state}} = sort {$a cmp $b} @{$details->{$state}};
+
if (scalar @{$count->{$state}}) {
printf "%s: %d", uc($state), scalar @{$count->{$state}};
if ($state_mapping{$state} > 0) {
print ": ", join(', ', @{$count->{$state}});
};
print "; ";
- $exit = $state_mapping{$state} unless defined $exit;
+ $exit = $state_mapping{$state} if ($state_mapping{$state} > $exit);
};
};
printf "unsigned: %d", scalar @{$count->{'unsigned'}};
print "\n";
-print $_ for (@details);
+for my $state (@$states) {
+ for (@{$details->{$state}}) {
+ s/\|/;/g;
+ print $_;
+ }
+}
exit $exit;