dsa-check-mirrorsync: Fix counting of out-of-date mirrors.
authorPeter Palfrader <peter@palfrader.org>
Mon, 2 Nov 2009 14:49:51 +0000 (15:49 +0100)
committerPeter Palfrader <peter@palfrader.org>
Mon, 2 Nov 2009 14:49:51 +0000 (15:49 +0100)
dsa-nagios-checks/checks/dsa-check-mirrorsync
dsa-nagios-checks/debian/changelog

index fc913b0..af37983 100755 (executable)
@@ -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'};
 }
index 6c8754c..c323893 100644 (file)
@@ -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 <weasel@debian.org>  Thu, 29 Oct 2009 19:09:36 +0100
+ -- Peter Palfrader <weasel@debian.org>  Mon, 02 Nov 2009 15:49:28 +0100
 
 dsa-nagios-checks (83) stable; urgency=low