diff options
Diffstat (limited to 'plugins-scripts/check_log.sh')
| -rwxr-xr-x | plugins-scripts/check_log.sh | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index a9ff06ad..be4c7be1 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 |
| @@ -58,7 +58,6 @@ | |||
| 58 | # Paths to commands used in this script. These | 58 | # Paths to commands used in this script. These |
| 59 | # may have to be modified to match your system setup. | 59 | # may have to be modified to match your system setup. |
| 60 | 60 | ||
| 61 | ECHO="/bin/echo" | ||
| 62 | GREP="/bin/egrep" | 61 | GREP="/bin/egrep" |
| 63 | DIFF="/bin/diff" | 62 | DIFF="/bin/diff" |
| 64 | TAIL="/bin/tail" | 63 | TAIL="/bin/tail" |
| @@ -85,7 +84,7 @@ print_help() { | |||
| 85 | echo "" | 84 | echo "" |
| 86 | print_usage | 85 | print_usage |
| 87 | echo "" | 86 | echo "" |
| 88 | echo "Log file pattern detector plugin for Nagios" | 87 | echo "Log file pattern detector plugin for monitoring" |
| 89 | echo "" | 88 | echo "" |
| 90 | support | 89 | support |
| 91 | } | 90 | } |
| @@ -166,10 +165,10 @@ done | |||
| 166 | # If the source log file doesn't exist, exit | 165 | # If the source log file doesn't exist, exit |
| 167 | 166 | ||
| 168 | if [ ! -e $logfile ]; then | 167 | if [ ! -e $logfile ]; then |
| 169 | $ECHO "Log check error: Log file $logfile does not exist!\n" | 168 | echo "Log check error: Log file $logfile does not exist!" |
| 170 | exit $STATE_UNKNOWN | 169 | exit $STATE_UNKNOWN |
| 171 | elif [ ! -r $logfile ] ; then | 170 | elif [ ! -r $logfile ] ; then |
| 172 | $ECHO "Log check error: Log file $logfile is not readable!\n" | 171 | echo "Log check error: Log file $logfile is not readable!" |
| 173 | exit $STATE_UNKNOWN | 172 | exit $STATE_UNKNOWN |
| 174 | fi | 173 | fi |
| 175 | 174 | ||
| @@ -179,7 +178,7 @@ fi | |||
| 179 | 178 | ||
| 180 | if [ ! -e $oldlog ]; then | 179 | if [ ! -e $oldlog ]; then |
| 181 | $CAT $logfile > $oldlog | 180 | $CAT $logfile > $oldlog |
| 182 | $ECHO "Log check data initialized...\n" | 181 | echo "Log check data initialized..." |
| 183 | exit $STATE_OK | 182 | exit $STATE_OK |
| 184 | fi | 183 | fi |
| 185 | 184 | ||
| @@ -208,10 +207,10 @@ $RM -f $tempdiff | |||
| 208 | $CAT $logfile > $oldlog | 207 | $CAT $logfile > $oldlog |
| 209 | 208 | ||
| 210 | if [ "$count" = "0" ]; then # no matches, exit with no error | 209 | if [ "$count" = "0" ]; then # no matches, exit with no error |
| 211 | $ECHO "Log check ok - 0 pattern matches found\n" | 210 | echo "Log check ok - 0 pattern matches found" |
| 212 | exitstatus=$STATE_OK | 211 | exitstatus=$STATE_OK |
| 213 | else # Print total matche count and the last entry we found | 212 | else # Print total matche count and the last entry we found |
| 214 | $ECHO "($count) $lastentry" | 213 | echo "($count) $lastentry" |
| 215 | exitstatus=$STATE_CRITICAL | 214 | exitstatus=$STATE_CRITICAL |
| 216 | fi | 215 | fi |
| 217 | 216 | ||
