From 3f297792aafe30f8dba03600a5306cf0e5eec90c Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 2 Nov 2009 15:49:51 +0100 Subject: [PATCH] dsa-check-mirrorsync: Fix counting of out-of-date mirrors. --- dsa-nagios-checks/checks/dsa-check-mirrorsync | 9 +++++---- dsa-nagios-checks/debian/changelog | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dsa-nagios-checks/checks/dsa-check-mirrorsync b/dsa-nagios-checks/checks/dsa-check-mirrorsync index fc913b0..af37983 100755 --- a/dsa-nagios-checks/checks/dsa-check-mirrorsync +++ b/dsa-nagios-checks/checks/dsa-check-mirrorsync @@ -105,7 +105,7 @@ 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; @@ -120,10 +120,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'}; } diff --git a/dsa-nagios-checks/debian/changelog b/dsa-nagios-checks/debian/changelog index 6c8754c..c323893 100644 --- a/dsa-nagios-checks/debian/changelog +++ b/dsa-nagios-checks/debian/changelog @@ -2,8 +2,9 @@ dsa-nagios-checks (8X) Xtable; urgency=low * dsa-check-mirrorsync: Handle case where we cannot parse a tracefile better (do not reference undefined values, properly exit with UNKNOWN). + * dsa-check-mirrorsync: Fix counting of out-of-date mirrors. - -- Peter Palfrader Thu, 29 Oct 2009 19:09:36 +0100 + -- Peter Palfrader Mon, 02 Nov 2009 15:49:28 +0100 dsa-nagios-checks (83) stable; urgency=low -- 2.20.1