Dependency on program check seems to be failing

Issue #244 resolved
Former user created an issue

Hi,

I'm trying to insert a dependency on a program check into my monitrc but monit 5.12 in this case does not seem to work correctly. I tried to create the most simple scenario in order to exclude "exotic" causes...So I have a monitrc with:

...
check program "should-fail" with path "/bin/bash -c '/bin/false'"
  if status != 0 then alert

check program "ok" with path "/bin/touch /monit_was_here"
  if status != 0 then alert
  depends on should-fail

check process "ping_1"
  matching "ping"
  start program = "/bin/sh -c '/etc/monit/programs/localhost/ping_1.1441200522.sh &'" as uid "root" and gid "root" with timeout 4 seconds
  stop program  = "/usr/bin/killall 'ping'" as uid "root" and gid "root"
  depends on should-fail
...

When I run the monit daemon, the file /monit_was_here exists and monit status reports:

...
Program 'should-fail'
  status                            Status failed
  monitoring status                 Monitored
  last started                      Wed, 02 Sep 2015 16:58:37
  last exit value                   1
  data collected                    Wed, 02 Sep 2015 16:58:37

Program 'ok'
  status                            Status ok
  monitoring status                 Monitored
  last started                      Wed, 02 Sep 2015 16:58:37
  last exit value                   0
  data collected                    Wed, 02 Sep 2015 16:58:37

Process 'ping_1'
  status                            Running
  monitoring status                 Monitored
  pid                               10171
  parent pid                        1
  uid                               0
  effective uid                     0
  gid                               0
  uptime                            3m 
  children                          1
  memory                            1.1 MB
  memory total                      1.9 MB
  memory percent                    0.2%
  memory percent total              0.3%
  cpu percent                       0.0%
  cpu percent total                 0.0%
  data collected                    Wed, 02 Sep 2015 16:57:36

...

Even though the service should have not been started...It seems that monit captures the exit status of /bin/false correctly but when it comes to the dependency it seems to be just ignoring it. Am I missing something? Or it's just that "depends on" does not support program checks yet? Nothing useful in the logs. Could you please help me on this one?

Thanks a lot in advance.

Cheers, Gyuri

Comments (6)

  1. Gyorgy Demarcsek

    I have retested with 5.15 ß. For the process check "ping_1" it seems to be working:

    Oct 13 15:15:38 HOST monit[23361]: 'ping_1' failed to start -- could not start required services: 'should-fail'

    However, the program check "ok" got still executed, resulting in a file /monit_was_here which was not expected. Could you please reopen the issue maybe?

  2. Log in to comment