110 my $gz = gzopen($logfile, "rb") |
110 my $gz = gzopen($logfile, "rb") |
111 or print "RSNAPSHOT CRITICAL: Cannot open $logfile: $gzerrno\n" |
111 or print "RSNAPSHOT CRITICAL: Cannot open $logfile: $gzerrno\n" |
112 and exit $ERRORS{CRITICAL}; |
112 and exit $ERRORS{CRITICAL}; |
113 while ($gz->gzreadline($_) > 0) { |
113 while ($gz->gzreadline($_) > 0) { |
114 next unless (/^\[$date/); |
114 next unless (/^\[$date/); |
|
115 $found_in_file = $logfile; |
115 if (/^\[$date:.*ERROR/) { |
116 if (/^\[$date:.*ERROR/) { |
116 $error = $_; |
117 $error = $_; |
117 last; |
118 last; |
118 } |
119 } |
119 $found_in_file = $logfile; |
|
120 } |
120 } |
121 print "RSNAPSHOT CRITICAL: Error reading from $logfile: $gzerrno\n" |
121 print "RSNAPSHOT CRITICAL: Error reading from $logfile: $gzerrno\n" |
122 and exit $ERRORS{CRITICAL} |
122 and exit $ERRORS{CRITICAL} |
123 if $gzerrno != Z_STREAM_END; |
123 if $gzerrno != Z_STREAM_END; |
124 $gz->gzclose(); |
124 $gz->gzclose(); |
125 } else { |
125 } else { |
126 open(FH, $logfile) |
126 open(FH, $logfile) |
127 or print "RSNAPSHOT CRITICAL: $logfile - $!\n" |
127 or print "RSNAPSHOT CRITICAL: $logfile - $!\n" |
128 and exit $ERRORS{CRITICAL}; |
128 and exit $ERRORS{CRITICAL}; |
129 while (<FH>) { |
129 while (<FH>) { |
|
130 $found_in_file = $logfile; |
130 next unless (/^\[$date/); |
131 next unless (/^\[$date/); |
131 if (/^\[$date:.*ERROR/) { |
132 if (/^\[$date:.*ERROR/) { |
132 $error = $_; |
133 $error = $_; |
133 last; |
134 last; |
134 } |
135 } |
135 $found_in_file = $logfile; |
|
136 } |
136 } |
137 close(FH); |
137 close(FH); |
138 } |
138 } |
139 |
139 |
140 last if $found_in_file; |
140 last if $found_in_file; |
141 |
141 |
142 } |
142 } |
143 |
143 |
144 unless ($found_in_file) { |
144 $error |= "can't find rsnapshot run from [$date]\n" unless ($found_in_file); |
145 $error = "can't find rsnapshot run from [$date]\n"; |
|
146 } |
|
147 |
145 |
148 if ($error) { |
146 if ($error) { |
149 print "RSNAPSHOT CRITICAL: $error"; |
147 print "RSNAPSHOT CRITICAL: $error"; |
150 exit $ERRORS{CRITICAL}; |
148 exit $ERRORS{CRITICAL}; |
151 } else { |
149 } else { |