monit-general
[Top][All Lists]
Advanced

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

RE: Monit and SQL query


From: Charles Pino
Subject: RE: Monit and SQL query
Date: Mon, 17 Sep 2012 18:06:09 +0800

hello again Callum and Nestor thanks for the replies.
 

can you point me exactly where i can put in how often the check will be? i dont want the frequency of the checking setting be global. but somewhat local to the script and ideally every X hours?


check program lastcall with path "/root/mysql.py"
if status !=0   then alert


i am only getting one email right now.  and that is because the value of the said field (timestamp) in mysql is already more than 12 which is what i wanted. if the timestamp is more than 12. it should send an alert.

and its not sending anything anymore. except if i restart mysql


charles


> Subject: Re: Monit and SQL query
> From: address@hidden
> To: address@hidden
> Date: Mon, 17 Sep 2012 10:46:59 +0100
>
> Hola Charles,
>
> Monit will run the script every check (so every minute maybe?) and alert
> if the exit code matches. You don't need to use cron or otherwise, monit
> will itself run the script. Is that what you were asking?
>
> Cheers - Callum.
>
> On Mon, 2012-09-17 at 05:19 -0400, Nestor Urquiza wrote:
> > Monit will send you 1 alert for the failure and 1 when it is back to
> > normal even if you check every minute. Go with cron and you will end
> > up with several emails depending on how often you check.
> >
> >
> > Furthermore use monit and you will be able to stop all checks at once
> > with one command. Go with cron and you will have to edit a file and
> > hope you did not do a typo.
> >
> >
> > If you are just checking once in a day and no more than a couple of
> > checks cron will probably do as well as monit.
> >
> >
> >
> >
> > On Sep 16, 2012, at 11:33 PM, Charles Pino <address@hidden>
> > wrote:
> >
> >
> >
> > > :) thank you. i think i would just stick with the defaults for now.
> > > looks pretty complicated for a noob like me.
> > >
> > >
> > > so, how would i make monit execute the script? as the script checks
> > > if the field has been written for the past 12hrs.
> > >
> > >
> > > im initially thinking i would just do all this in cron.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > > Subject: Re: Monit and SQL query
> > > > From: address@hidden
> > > > Date: Sun, 16 Sep 2012 17:20:31 +0200
> > > > To: address@hidden
> > > >
> > > > Yes, more or less. To have Monit send an alert message that is
> > > printed from your script, follow this receipt
> > > >
> > > > 1) Add a custom mail format to the check, where the message body
> > > is just $DESCRIPTION:
> > > >
> > > > check program foo with path "/path/to/foo.sh"
> > > > alert address@hidden mail-format { message: $DESCRIPTION }
> > > > if status != 0 then alert
> > > >
> > > > 2) Make your script write the error message you want to send to
> > > stderr. Here is a demo script I used to test this:
> > > >
> > > > foo.sh:
> > > >
> > > > #!/bin/bash
> > > >
> > > > echo 1>&2 "Hello this is an error message from $0";
> > > > exit 1;
> > > >
> > > > 3) The alert mail you get from Monit will look something like
> > > this.
> > > >
> > > > status failed (1) for /path/to/foo.sh -- Error: Hello this is an
> > > error message from /path/to/foo.sh
> > > >
> > > > The prefix 'status failed (1) for /path/to/foo.sh -- Error: ' is
> > > hardcoded in validate.c:check_program and if it bothers you, just
> > > remove the prefix.
> > > >
> > > > That is replace this line
> > > >
> > > > Event_post(s, Event_Status, STATE_FAILED, status->action, "status
> > > failed (%d) for %s -- Error: %s..", s->program->exitStatus, s->path,
> > > buf);
> > > >
> > > > With this one:
> > > >
> > > > Event_post(s, Event_Status, STATE_FAILED, status->action, "%s",
> > > buf);
> > > >
> > > > and recompile Monit.
> > > >
> > > > Hope this helps.
> > > >
> > > >
> > > > On Sep 16, 2012, at 4:33 PM, Charles Pino
> > > <address@hidden> wrote:
> > > >
> > > > > i had it somehow working, but the alerts message / email is
> > > somewhat not really nice to look at.
> > > > >
> > > > >
> > > > > Status failed Service foo
> > > > >
> > > > > Date: Sun, 16 Sep 2012 21:12:38
> > > > > Action: alert
> > > > > Host: orecx
> > > > > Description: status failed (1) for /root/mysql.py. Error: 1
> > > > > .
> > > > >
> > > > > Your faithful employee,
> > > > > Monit
> > > > >
> > > > >
> > > > > my question is. can i change the status failed service to my own
> > > message? as well as
> > > > > Description: status failed (1) for /root/mysql.py. Error: 1 --
> > > id like to have it say that the db hasnt been any writes in the past
> > > 12 hrs etc etc.
> > > >
> > > >
> > > >
> > > > --
> > > > 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]