Hm, it is interresting.
I just edited my script, the exit value is now greater than 0 and monit
still working with 0.
the script is now look like:
#!/bin/bash
errorcount=`tail -n 10 contego.log | grep "Error" | wc -l`
if [ $errorcount -gt 0 ]; then
exit $errorcount
else
exit
fi
The last exit value is:
root@InfinityTV:/mnt/vouchers# ./logtest.sh
root@InfinityTV:/mnt/vouchers# echo $?
10
root@InfinityTV:/mnt/vouchers#
So i don't know what i am doing wrong.
Martin
On 5. 6. 2014 13:56, Martin Pala wrote:
yes
You can add echo to print some error message before exit, but the exit value is
what is checked by Monit
On 05 Jun 2014, at 13:50, Martin Vaner <[email protected]> wrote:
So if i understand correctly, i should have something like "exit 1" instead of
"echo $errorcount".
Regards,
Martin
On 5. 6. 2014 13:48, Martin Pala wrote:
Hello,
Monit check for exit value - not output (echo vs. exit).
Regards,
Martin
On 05 Jun 2014, at 13:45, Martin Vaner <[email protected]> wrote:
Hello all,
i have a one little problem. I have bash script, which look like this (somebody
have already seen it here).
#!/bin/bash
errorcount=`tail -n 10 contego.log | grep "Error" | wc -l`
if [ $errorcount -gt 0 ]; then
echo $errorcount
else
echo 0
fi
When i run the scrip from the console, and the file contego.log contains
"Error" word, the output is:
root@InfinityTV:/mnt/vouchers# ./logtest.sh
10
But Monit still working with exit value 0, so it doesn't send alerts when the
file contains 10 Errors.
Program 'contego_errors'
status Status ok
monitoring status Monitored
last started Thu, 05 Jun 2014 13:28:28
last exit value 0
data collected Thu, 05 Jun 2014 13:28:28
The monit config is look like this:
check program contego_errors with path /mnt/vouchers/logtest.sh
if status != 0 then alert
Do you have some tips, how to get this to work?
Thanks,
Martin
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general