monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monit $ Bash wrong exit value?


From: Martin Vaner
Subject: Re: Monit $ Bash wrong exit value?
Date: Thu, 05 Jun 2014 14:34:05 +0200
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

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:
address@hidden:/mnt/vouchers# ./logtest.sh
address@hidden:/mnt/vouchers# echo $?
10
address@hidden:/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 <address@hidden> 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 <address@hidden> 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:
address@hidden:/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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]