[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Monit $ Bash wrong exit value?
From: |
Martin Pala |
Subject: |
Re: Monit $ Bash wrong exit value? |
Date: |
Thu, 5 Jun 2014 13:56:35 +0200 |
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