monit-general
[Top][All Lists]
Advanced

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

Re: Configuring a warning using a shell script


From: Jason Levitt
Subject: Re: Configuring a warning using a shell script
Date: Fri, 2 May 2014 23:15:07 -0500

If you look at the bottom of this page:
http://mmonit.com/wiki/Monit/ConfigurationExamples
There is a clear example of monitoring using a shell script:

Monitor HDD Temperature:

check program HDD_80 with path "/usr/local/etc/monit/scripts/ada0_temp.sh"
    if status > 45 then alert
    group temperature

Script /usr/local/etc/monit/scripts/ada0_temp.sh

#!/bin/sh
TP=`/usr/local/sbin/smartctl -a /dev/ada0 | grep Temp | awk -F " "
'{printf "%d",$10}'`
echo $TP # for debug only
exit $TP

So, all this shell script does is exit with a status code. The alert
script just runs the script
and then tests for the status code value.

Is there anything else that one needs to do to get this to work?
Is the monit daemon executing the shell script each cycle?

J

On Fri, May 2, 2014 at 5:32 PM, Martin Vaner <address@hidden> wrote:
> Hi,
>
> it seems that you have wrong config file. I am using the number to check the
> log file if it contains some Errors.
> I am using this combination and it is working.
>
> My little easy bash script is:
>
> #!/bin/bash
>
> errorcount=`tail -n 10 contego.log | grep "Error" | wc -l`
> if [ $errorcount -gt 0 ]; then
> exit $?
> else
> echo $errorcount
> exit 0
> fi
>
> And /etc/monit/monitrc is contain these lines:
>
> check program Contego_Errors with path /mnt/vouchers/logtest.sh
>     if status != 0 then alert
>
> Seems you have something wrong in monitrc file or in the config file in
> conf.d
>
> By the way, i had also a little mistake in the IF part of my bash script and
> i spent a lot of time to find it. But found.
>
> Regards,
>
> Martin
>
>
>
> On 2.5.2014 23:52, Jason Levitt wrote:
>
> Hi Martin,
>
>  There are no notices in the monit log file, and, as I mentioned, the
> M/Monit console shows
> that everythiing is "ok" (I guess).  If monit couldn't execute it,
> wouldn't it put something in the log
> file?
>
>   Mode of the shell script is 777 and I've executed it successfully as
> both a regular user and root.
>   And the first line of the script is  #!/bin/bash
>
> Jan:
>
>   How does that affect the alerting? I've been sitting here for an
> hour or more. Shouldn't
> I see some warnings in M/Monit?
>
> J
>
> On Fri, May 2, 2014 at 4:17 PM, Martin Vaner <address@hidden> wrote:
>
> Hi Jason,
>
> Are you sure that Monit is able tonrun the script? Can you please provide
> the source of your script?
>
> I had an issue like this before few months ago.
>
> Thanks.
>
>
> On 2. května 2014 23:01:02 CEST, Jason Levitt <address@hidden> wrote:
>
> I'm trying to configure a simple warning using a bash script.
> I used the example at the bottom of this page as a starting
> point:  http://mmonit.com/wiki/Monit/ConfigurationExamples
>
> My bash script outputs an exit status:
>
> exit $number
>
> I've run the script manually (it's mode 777), and it outputs nothing, but
> has an exit status that is non-zero.
>
> Then in my monitrc file,  I have:
>
> check program CheckQueueSize with path "/var/opt/qcheck.sh"
>      if status > 5 then alert
>
> In M/Monit, it shows Program "CheckQueueSize" with status "Status ok" with
> 0 Events and the light is green.
>
> However, when I run the shell script manually, it always outputs numbers
> greater than 5.
>
> Is the shell script not being executed?  Or is M/Monit just not warning
> me? I'm confused.
>
> J
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
> --
> Odesláno z mého telefonu s Androidem pomocí pošty K-9 Mail. Omluvte prosím
> moji stručnost.
>
>



reply via email to

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