report actual error instead of "can't find rsnapshot run"
authorMatthias Förste <foerste@schlittermann.de>
Tue, 26 Mar 2013 11:28:02 +0100
changeset 13 7646f39cf5cc
parent 12 3243849b73c6
child 14 428feaf9b859
report actual error instead of "can't find rsnapshot run"
check_rsnapshot.pl
--- a/check_rsnapshot.pl	Tue Mar 26 10:31:41 2013 +0100
+++ b/check_rsnapshot.pl	Tue Mar 26 11:28:02 2013 +0100
@@ -112,11 +112,11 @@
               and exit $ERRORS{CRITICAL};
             while ($gz->gzreadline($_) > 0) {
                 next unless (/^\[$date/);
+                $found_in_file = $logfile;
                 if (/^\[$date:.*ERROR/) {
                     $error = $_;
                     last;
                 }
-                $found_in_file = $logfile;
             }
             print "RSNAPSHOT CRITICAL: Error reading from $logfile: $gzerrno\n"
               and exit $ERRORS{CRITICAL}
@@ -127,12 +127,12 @@
               or print "RSNAPSHOT CRITICAL: $logfile - $!\n"
               and exit $ERRORS{CRITICAL};
             while (<FH>) {
+                $found_in_file = $logfile;
                 next unless (/^\[$date/);
                 if (/^\[$date:.*ERROR/) {
                     $error = $_;
                     last;
                 }
-                $found_in_file = $logfile;
             }
             close(FH);
         }
@@ -141,9 +141,7 @@
 
     }
 
-    unless ($found_in_file) {
-        $error = "can't find rsnapshot run from [$date]\n";
-    }
+    $error |= "can't find rsnapshot run from [$date]\n" unless ($found_in_file); 
 
     if ($error) {
         print "RSNAPSHOT CRITICAL: $error";