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.sh28
1 files changed, 11 insertions, 17 deletions
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index be4c7be..8653a5e 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
61GREP="/bin/egrep"
62DIFF="/bin/diff"
63TAIL="/bin/tail"
64CAT="/bin/cat"
65RM="/bin/rm"
66CHMOD="/bin/chmod"
67TOUCH="/bin/touch"
68
69PROGNAME=`/bin/basename $0` 61PROGNAME=`/bin/basename $0`
70PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 62PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
71REVISION="@NP_VERSION@" 63REVISION="@NP_VERSION@"
72PATH="@trusted_path@" 64PATH="@TRUSTED_PATH@"
65
66export 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
179if [ ! -e $oldlog ]; then 173if [ ! -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
183fi 177fi
@@ -191,20 +185,20 @@ if [ -x /bin/mktemp ]; then
191else 185else
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
196fi 190fi
197 191
198$DIFF $logfile $oldlog | $GREP -v "^>" > $tempdiff 192diff $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
201count=`$GREP -c "$query" $tempdiff` 195count=`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
204lastentry=`$GREP "$query" $tempdiff | $TAIL -1` 198lastentry=`grep "$query" $tempdiff | tail -1`
205 199
206$RM -f $tempdiff 200rm -f $tempdiff
207$CAT $logfile > $oldlog 201cat $logfile > $oldlog
208 202
209if [ "$count" = "0" ]; then # no matches, exit with no error 203if [ "$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"