aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts/check_log.sh
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-02-28 13:28:33 +0100
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2014-02-28 13:28:33 +0100
commitc08d6a429ba0e0cd3642ba2c2fe85687472ee22f (patch)
tree396a37ae462543f0e28f36501c30796b3eb91249 /plugins-scripts/check_log.sh
parente260efb25690b13002a0bf432507f66bdad90f02 (diff)
downloadmonitoring-plugins-c08d6a429ba0e0cd3642ba2c2fe85687472ee22f.tar.gz
Replace "plugins-scripts/subst.in" foo
Remove the buggy and complex awk(1) magic in "plugins-scripts/subst.in" in favor of simple sed(1) substitutions. The plugins in the "plugins-scripts" directory now always use the PATH specified via "./configure --trusted-path", or the default PATH hard-coded in "configure.ac". Fixes #1242.
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 be4c7be1..8653a5e1 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -58,18 +58,12 @@
# Paths to commands used in this script. These
# may have to be modified to match your system setup.
-GREP="/bin/egrep"
-DIFF="/bin/diff"
-TAIL="/bin/tail"
-CAT="/bin/cat"
-RM="/bin/rm"
-CHMOD="/bin/chmod"
-TOUCH="/bin/touch"
-
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION="@NP_VERSION@"
-PATH="@trusted_path@"
+PATH="@TRUSTED_PATH@"
+
+export PATH
. $PROGPATH/utils.sh
@@ -177,7 +171,7 @@ fi
# the old diff file and exit
if [ ! -e $oldlog ]; then
- $CAT $logfile > $oldlog
+ cat $logfile > $oldlog
echo "Log check data initialized..."
exit $STATE_OK
fi
@@ -191,20 +185,20 @@ if [ -x /bin/mktemp ]; then
else
tempdiff=`/bin/date '+%H%M%S'`
tempdiff="/tmp/check_log.${tempdiff}"
- $TOUCH $tempdiff
- $CHMOD 600 $tempdiff
+ touch $tempdiff
+ chmod 600 $tempdiff
fi
-$DIFF $logfile $oldlog | $GREP -v "^>" > $tempdiff
+diff $logfile $oldlog | grep -v "^>" > $tempdiff
# Count the number of matching log entries we have
-count=`$GREP -c "$query" $tempdiff`
+count=`grep -c "$query" $tempdiff`
# Get the last matching entry in the diff file
-lastentry=`$GREP "$query" $tempdiff | $TAIL -1`
+lastentry=`grep "$query" $tempdiff | tail -1`
-$RM -f $tempdiff
-$CAT $logfile > $oldlog
+rm -f $tempdiff
+cat $logfile > $oldlog
if [ "$count" = "0" ]; then # no matches, exit with no error
echo "Log check ok - 0 pattern matches found"