diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2021-12-20 14:57:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 14:57:11 (GMT) |
commit | ebf5cd2afef33aa4e6b680a88deb804d104c68f5 (patch) | |
tree | 65b9e32bcca9086c792be43e05d47badf37178b6 /plugins-scripts/check_log.sh | |
parent | 78801192cf55ed01f284c93caa3eb0ba6842827c (diff) | |
parent | c1bf69c3a6a52c714e27107219e402bbecd7c000 (diff) | |
download | monitoring-plugins-ebf5cd2afef33aa4e6b680a88deb804d104c68f5.tar.gz |
Merge pull request #1732 from RincewindsHat/check_log_missing_oldlog_abort
Missing oldlog now aborts check_log
Diffstat (limited to 'plugins-scripts/check_log.sh')
-rwxr-xr-x | plugins-scripts/check_log.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index 6113123..fdb5741 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -43,6 +43,10 @@ | |||
43 | # check the same <log_file> for pattern matches. This is necessary | 43 | # check the same <log_file> for pattern matches. This is necessary |
44 | # because of the way the script operates. | 44 | # because of the way the script operates. |
45 | # | 45 | # |
46 | # 4. This plugin does NOT have an understanding of logrotation or similar | ||
47 | # mechanisms. Therefore bad timing could lead to missing events | ||
48 | # | ||
49 | # | ||
46 | # Examples: | 50 | # Examples: |
47 | # | 51 | # |
48 | # Check for login failures in the syslog... | 52 | # Check for login failures in the syslog... |
@@ -207,6 +211,11 @@ elif [ ! -r "$logfile" ] ; then | |||
207 | echo "Log check error: Log file $logfile is not readable!" | 211 | echo "Log check error: Log file $logfile is not readable!" |
208 | exit "$STATE_UNKNOWN" | 212 | exit "$STATE_UNKNOWN" |
209 | fi | 213 | fi |
214 | # If no oldlog was given this can not work properly, abort then | ||
215 | if [ -z "$oldlog" ]; then | ||
216 | echo "Oldlog parameter is needed" | ||
217 | exit $STATE_UNKNOWN | ||
218 | fi | ||
210 | 219 | ||
211 | # If the old log file doesn't exist, this must be the first time | 220 | # If the old log file doesn't exist, this must be the first time |
212 | # we're running this test, so copy the original log file over to | 221 | # we're running this test, so copy the original log file over to |
@@ -256,7 +265,7 @@ cat "$logfile" > "$oldlog" | |||
256 | if [ "$count" = "0" ]; then # no matches, exit with no error | 265 | if [ "$count" = "0" ]; then # no matches, exit with no error |
257 | echo "Log check ok - 0 pattern matches found" | 266 | echo "Log check ok - 0 pattern matches found" |
258 | exitstatus=$STATE_OK | 267 | exitstatus=$STATE_OK |
259 | else # Print total matche count and the last entry we found | 268 | else # Print total match count and the last entry we found |
260 | echo "($count) $entry" | 269 | echo "($count) $entry" |
261 | exitstatus=$STATE_CRITICAL | 270 | exitstatus=$STATE_CRITICAL |
262 | fi | 271 | fi |