summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_log.sh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts/check_log.sh')
-rwxr-xr-xplugins-scripts/check_log.sh29
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index a1bfb48..54408cb 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Log file pattern detector plugin for Nagios 3# Log file pattern detector plugin for monitoring
4# Written by Ethan Galstad (nagios@nagios.org) 4# Written by Ethan Galstad (nagios@nagios.org)
5# Last Modified: 07-31-1999 5# Last Modified: 07-31-1999
6# 6#
@@ -29,15 +29,15 @@
29# 29#
30# If you use this plugin make sure to keep the following in mind: 30# If you use this plugin make sure to keep the following in mind:
31# 31#
32# 1. The "max_attempts" value for the service should be 1, as this 32# 1. The "max_attempts" value for the service should be 1, as this will
33# will prevent Nagios from retrying the service check (the 33# prevent the monitoring system from retrying the service check (the
34# next time the check is run it will not produce the same results). 34# next time the check is run it will not produce the same results).
35# 35#
36# 2. The "notify_recovery" value for the service should be 0, so that 36# 2. The "notify_recovery" value for the service should be 0, so that the
37# Nagios does not notify you of "recoveries" for the check. Since 37# monitoring system does not notify you of "recoveries" for the check.
38# pattern matches in the log file will only be reported once and not 38# Since pattern matches in the log file will only be reported once and
39# the next time, there will always be "recoveries" for the service, even 39# not the next time, there will always be "recoveries" for the service,
40# though recoveries really don't apply to this type of check. 40# even though recoveries really don't apply to this type of check.
41# 41#
42# 3. You *must* supply a different <old_file_log> for each service that 42# 3. You *must* supply a different <old_file_log> for each service that
43# you define to use this plugin script - even if the different services 43# you define to use this plugin script - even if the different services
@@ -60,7 +60,6 @@
60# TV: removed PATH restriction. Need to think more about what this means overall 60# TV: removed PATH restriction. Need to think more about what this means overall
61#PATH="" 61#PATH=""
62 62
63ECHO="/bin/echo"
64GREP="/bin/egrep" 63GREP="/bin/egrep"
65DIFF="/bin/diff" 64DIFF="/bin/diff"
66TAIL="/bin/tail" 65TAIL="/bin/tail"
@@ -86,7 +85,7 @@ print_help() {
86 echo "" 85 echo ""
87 print_usage 86 print_usage
88 echo "" 87 echo ""
89 echo "Log file pattern detector plugin for Nagios" 88 echo "Log file pattern detector plugin for monitoring"
90 echo "" 89 echo ""
91 support 90 support
92} 91}
@@ -167,10 +166,10 @@ done
167# If the source log file doesn't exist, exit 166# If the source log file doesn't exist, exit
168 167
169if [ ! -e $logfile ]; then 168if [ ! -e $logfile ]; then
170 $ECHO "Log check error: Log file $logfile does not exist!\n" 169 echo "Log check error: Log file $logfile does not exist!"
171 exit $STATE_UNKNOWN 170 exit $STATE_UNKNOWN
172elif [ ! -r $logfile ] ; then 171elif [ ! -r $logfile ] ; then
173 $ECHO "Log check error: Log file $logfile is not readable!\n" 172 echo "Log check error: Log file $logfile is not readable!"
174 exit $STATE_UNKNOWN 173 exit $STATE_UNKNOWN
175fi 174fi
176 175
@@ -180,7 +179,7 @@ fi
180 179
181if [ ! -e $oldlog ]; then 180if [ ! -e $oldlog ]; then
182 $CAT $logfile > $oldlog 181 $CAT $logfile > $oldlog
183 $ECHO "Log check data initialized...\n" 182 echo "Log check data initialized..."
184 exit $STATE_OK 183 exit $STATE_OK
185fi 184fi
186 185
@@ -209,10 +208,10 @@ $RM -f $tempdiff
209$CAT $logfile > $oldlog 208$CAT $logfile > $oldlog
210 209
211if [ "$count" = "0" ]; then # no matches, exit with no error 210if [ "$count" = "0" ]; then # no matches, exit with no error
212 $ECHO "Log check ok - 0 pattern matches found\n" 211 echo "Log check ok - 0 pattern matches found"
213 exitstatus=$STATE_OK 212 exitstatus=$STATE_OK
214else # Print total matche count and the last entry we found 213else # Print total matche count and the last entry we found
215 $ECHO "($count) $lastentry" 214 echo "($count) $lastentry"
216 exitstatus=$STATE_CRITICAL 215 exitstatus=$STATE_CRITICAL
217fi 216fi
218 217