diff options
Diffstat (limited to 'plugins-scripts/check_log.sh')
| -rwxr-xr-x | plugins-scripts/check_log.sh | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index be4c7be1..8653a5e1 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
| @@ -58,18 +58,12 @@ | |||
| 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 | GREP="/bin/egrep" | ||
| 62 | DIFF="/bin/diff" | ||
| 63 | TAIL="/bin/tail" | ||
| 64 | CAT="/bin/cat" | ||
| 65 | RM="/bin/rm" | ||
| 66 | CHMOD="/bin/chmod" | ||
| 67 | TOUCH="/bin/touch" | ||
| 68 | |||
| 69 | PROGNAME=`/bin/basename $0` | 61 | PROGNAME=`/bin/basename $0` |
| 70 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 62 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
| 71 | REVISION="@NP_VERSION@" | 63 | REVISION="@NP_VERSION@" |
| 72 | PATH="@trusted_path@" | 64 | PATH="@TRUSTED_PATH@" |
| 65 | |||
| 66 | export PATH | ||
| 73 | 67 | ||
| 74 | . $PROGPATH/utils.sh | 68 | . $PROGPATH/utils.sh |
| 75 | 69 | ||
| @@ -177,7 +171,7 @@ fi | |||
| 177 | # the old diff file and exit | 171 | # the old diff file and exit |
| 178 | 172 | ||
| 179 | if [ ! -e $oldlog ]; then | 173 | if [ ! -e $oldlog ]; then |
| 180 | $CAT $logfile > $oldlog | 174 | cat $logfile > $oldlog |
| 181 | echo "Log check data initialized..." | 175 | echo "Log check data initialized..." |
| 182 | exit $STATE_OK | 176 | exit $STATE_OK |
| 183 | fi | 177 | fi |
| @@ -191,20 +185,20 @@ if [ -x /bin/mktemp ]; then | |||
| 191 | else | 185 | else |
| 192 | tempdiff=`/bin/date '+%H%M%S'` | 186 | tempdiff=`/bin/date '+%H%M%S'` |
| 193 | tempdiff="/tmp/check_log.${tempdiff}" | 187 | tempdiff="/tmp/check_log.${tempdiff}" |
| 194 | $TOUCH $tempdiff | 188 | touch $tempdiff |
| 195 | $CHMOD 600 $tempdiff | 189 | chmod 600 $tempdiff |
| 196 | fi | 190 | fi |
| 197 | 191 | ||
| 198 | $DIFF $logfile $oldlog | $GREP -v "^>" > $tempdiff | 192 | diff $logfile $oldlog | grep -v "^>" > $tempdiff |
| 199 | 193 | ||
| 200 | # Count the number of matching log entries we have | 194 | # Count the number of matching log entries we have |
| 201 | count=`$GREP -c "$query" $tempdiff` | 195 | count=`grep -c "$query" $tempdiff` |
| 202 | 196 | ||
| 203 | # Get the last matching entry in the diff file | 197 | # Get the last matching entry in the diff file |
| 204 | lastentry=`$GREP "$query" $tempdiff | $TAIL -1` | 198 | lastentry=`grep "$query" $tempdiff | tail -1` |
| 205 | 199 | ||
| 206 | $RM -f $tempdiff | 200 | rm -f $tempdiff |
| 207 | $CAT $logfile > $oldlog | 201 | cat $logfile > $oldlog |
| 208 | 202 | ||
| 209 | if [ "$count" = "0" ]; then # no matches, exit with no error | 203 | if [ "$count" = "0" ]; then # no matches, exit with no error |
| 210 | echo "Log check ok - 0 pattern matches found" | 204 | echo "Log check ok - 0 pattern matches found" |
