Hi,
I´ve been trying to run a simple plugin to run this bash program that read a text file and return the lines with “ERROR” word:
#!/bin/sh
DATEI=./test.txt
WORD="hallo"
STOP="end"
I=1
STATE=0
MSJ="OK no errors in logfile"
ERR=0
WAR=0
while $WORD != “end” ]
do
WORD=$(head -$I $DATEI | tail -1)
if $WORD != “ERROR” ]; then
M=2
else
ERR=`expr $ERR + 1`
MSJ="Errors in logfile: $ERR errors"
STATE=2
fi
I=`expr $I + 1`
done
echo $MSJ $STATE
exit $STATE
It works if I run it from de command line but it´s not giving me the right result when it´s run by nagios.
Any idea?
Thanks in advance!
August.