X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-mirrorsync;h=488a7bcbd99f228f0316fc156e58b43d7f94689e;hb=ba41213d86fa3d26a0ee0505bb7d72dcfe3d6559;hp=fc913b097489e32f3d6d132b4aaa5b858019895e;hpb=ed4ecf22253f559ae720fbd52dc79abb9e0694a6;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-mirrorsync b/dsa-nagios-checks/checks/dsa-check-mirrorsync index fc913b0..488a7bc 100755 --- a/dsa-nagios-checks/checks/dsa-check-mirrorsync +++ b/dsa-nagios-checks/checks/dsa-check-mirrorsync @@ -105,11 +105,12 @@ foreach my $slave (@slaves) { push @exitstatus, "Cannot parse tracefile on $slave"; }; print "$slave last synced $synctime\n" if $params->{'verbose'}; - $status->{$slave}->{'synced'} = $synctime; + $status->{$slave}->{'synced'} = $synctime; } else { push @exitstatus, "$slave broken: " . $response->status_line; $status->{$slave}->{'error'} = $response->status_line; + $status->{$slave}->{'synced'} = 0; $exitcode = $CRITICAL; push @critical, $slave; } @@ -120,10 +121,11 @@ my %seen; my $o_sync = scalar(grep !$seen{$_}++, map{$status->{$_}->{'synced'}} keys(%{$status})); if ($o_sync > 1) { $exitcode = $CRITICAL; - $o_sync -= 1; my @mirrors = sort { $status->{$a}->{'synced'} <=> $status->{$b}->{'synced'} } keys %{$status}; - push @exitstatus, "$o_sync mirror(s) not in sync (from oldest to newest): ". - join(",", splice(@mirrors,0,$o_sync)); + my @not_most_recent = grep { $status->{$_}->{'synced'} <=> $status->{$mirrors[-1]}->{'synced'} } @mirrors; + $o_sync = scalar @not_most_recent; + push @exitstatus, "$o_sync mirror(s) not in sync (from oldest to newest): ". + join(", ", @not_most_recent); } else { print "All mirrors unique\n" if $params->{'verbose'}; }