Thank you very much for the clarification.
cheers

> Subject: RE: Monit and SQL query
> From: [email protected]
> To: [email protected]
> Date: Tue, 11 Sep 2012 13:20:24 +0100
> 
> You need to write a script that is separate from monit. A shell /
> python / ruby / PHP / whatever script that will connect to MySQL, run
> your query, check the results to see if it is good or not, then exit
> with either exit status 0 (good) or exit status 1 (bad).
> 
> Then you create a check in monit which runs the script, and if the exit
> status is not 0, sends an alert.
> 
> check program myscript with path "/usr/local/bin/myscript.sh"
>                if status != 0 then alert
> 
> This checks the exit status of myscript.sh. So if it ends with exit(0)
> then monit does not send an alert, if it ends with exit(1) then monit
> will send an alert.
> 
> Writing myscript.sh is not a monit task, so maybe outside the scope of
> this mailing list, I'm not sure.
> 
> Cheers - Callum.
> 
> On Tue, 2012-09-11 at 20:11 +0800, Charles Pino wrote:
> > sorry the db is MySQL
> > and i am trying to read  the difference between the last written
> > record and the current time.
> > if its been 12 hours already. it should send an alert via monit.
> > 
> > 
> > problem is i am not really sure how to grep or an sql result that has
> > different values (not just 1 or 0)
> > 
> > 
> > if status != 0 then alert   -- should i still use status?  
> > 
> > 
> > sorry im completely new to monit.
> > 
> > 
> > 
> > ______________________________________________________________________
> > Date: Mon, 10 Sep 2012 14:51:42 -0400
> > Subject: Re: Monit and SQL query
> > From: [email protected]
> > To: [email protected]
> > 
> > Build a shell script that:
> > 1. will issue the command to your server (you did not say what kind of
> > sql server you have)
> > 2. will parse the result from the server using for example grep and
> > regex
> > 3. If the result is unexpected use 'exit 1' 
> > 4. Set in monit as Martin said
> > 
> > On Mon, Sep 10, 2012 at 6:34 AM, Charles Pino
> > <[email protected]> wrote:
> >         sql statement is supposed to evaluate if the result is >= to
> >         12 , if true then alert. 
> >         
> >         
> >          how do i put that in place of " PROCESS OUTPUT AND RETURN 1
> >         IF FAILED OTHERWISE 0" ??
> >         
> >         
> >         thanks
> >         
> >         
> >         
> >         ______________________________________________________________
> >         From: [email protected]
> >         Subject: Re: Monit and SQL query
> >         Date: Mon, 10 Sep 2012 09:06:11 +0200
> >         To: [email protected]
> >         
> >         
> >         Hello,
> >         
> >         
> >         you can use the "check program" to test the exit value of
> >         custom script. In this case the script can execute the SQL
> >         statement and return error if problem is found.
> >         
> >         
> >         Script skeleton:
> >         --8<--
> >         #!/bin/bash
> >         /ur/bin/mysql -e "SQL STATEMENT" ... | PROCESS OUTPUT AND
> >         RETURN 1 IF FAILED OTHERWISE 0
> >         --8<--
> >         
> >         
> >         Connection of the script with monit:
> >         --8<--
> >          check program myscript with path "/usr/local/bin/myscript.sh"
> >                if status != 0 then alert
> >         --8<--
> >         
> >         
> >         Regards,
> >         Martin
> >         
> >         
> >         
> >         On Sep 9, 2012, at 4:58 PM, Charles Pino
> >         <[email protected]> wrote:
> >         
> >                 Hello all,
> >                  is it possible to execute and SQL query and have
> >                 monit execute and alert or something else depending on
> >                 its response?
> >                 
> >                 
> >                  i have a sql query that queries a specific table. of
> >                 something hasnt been updated in that table for 12
> >                 hours. i need to send an alert or whatever. that the
> >                 table/field hasnt been updated.
> >                 
> >                 
> >                 please help.
> >                 
> >                 
> >                 thanks
> >                 
> >                 
> >                 --
> >                 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
> 
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
                                          
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to