Hi Tomas,
the initial check program implementation supported only one status test - we
have implemented support for multiple status tests, you can get the development
snapshot here:
http://www.mmonit.com/tmp/monit-5.5_20120510.tar.gz
Example syntax:
check program mytest with path "/usr/bin/mytest.sh"
if status == 2 for 2 cycles then exec "/usr/local/bin/fix_script.sh"
if status == 2 for 6 cycles then unmonitor
if status == 10 then alert
Regards,
Martin
On Apr 20, 2012, at 2:53 PM, Tomas Nunez wrote:
> Hi
>
> I'm trying to check the RC of a program. If the RC is 2, I want it to exec a
> script that would allegedly fix the problem. But if after 3 attempts, the RC
> is still 2, then I want monit to stop trying.
>
> So I put a check program like this:
>
> check program check_program with path "check_program" every 6 cycles
> if status == 2 for 6 cycles then unmonitor
> if status == 2 for 2 cycles then exec "fix_script.sh"
>
> Now I've found that I can have one or the other, not both. When I put both
> lines, just the latter applies:
>
> #monit -v
> Program Name = check_program
> Path = /path/to/check_program
> Monitoring mode = active
> Existence = if does not exist 1 times within 1 cycle(s) then
> restart else if succeeded 1 times within 1 cycle(s) then alert
> Status = if 'check_program' exit value = 2 within 600 seconds
> then exec 'fix_script.sh' timeout 0 cycle(s) else if succeeded 1 times within
> 1 cycle(s) then alert
> Every = Check service every 6 cycles
>
> And the other way around:
>
> check program check_program with path "check_program" every 6 cycles
> if status == 2 for 2 cycles then exec "fix_script.sh"
> if status == 2 for 6 cycles then unmonitor
>
> # monit -v
> Program Name = check_program
> Path = /path/to/check_program
> Monitoring mode = active
> Existence = if does not exist 1 times within 1 cycle(s) then
> restart else if succeeded 1 times within 1 cycle(s) then alert
> Status = if 'check_program' exit value = 2 within 600 seconds
> then unmonitor else if succeeded 1 times within 1 cycle(s) then alert
> Every = Check service every 6 cycles
>
> It's strange because I have put conditions on the same value in other checks,
> and it works alright:
>
> check process apache with pidfile /var/run/httpd.pid
> start program = "/etc/init.d/httpd start" with timeout 60 seconds
> stop program = "/etc/init.d/httpd stop"
> if cpu > 60% for 2 cycles then alert
> if cpu > 80% for 5 cycles then restart
>
> # monit -v
> (...)
> CPU usage limit = if greater than 80.0% 5 times within 5 cycle(s) then
> restart else if succeeded 1 times within 1 cycle(s) then alert
> CPU usage limit = if greater than 60.0% 2 times within 2 cycle(s) then
> alert else if succeeded 1 times within 1 cycle(s) then alert
>
> What am I missing?
>
> Thanks in advance,
>
> Tomàs
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general