Hi,

the start program currently requires that the program will run on the 
background (daemonize). You program doesn't detach and keeps monit as parent.

The following should fix it:

check process test with pidfile /Users/marmel01/Documents/foo.pid
      start program = "/bin/bash -c '/Users/marmel01/Documents/monittest.sh &'"
      stop program = "/bin/kill $(/bin/cat /Users/marmel01/Documents/foo.pid)”

Regards,
Martin
        


> On 19 Nov 2015, at 15:58, Mark Mellar <[email protected]> wrote:
> 
> Hi folks, 
> 
> I was wondering if someone here might be able to help me out with my current 
> monit problem. I’ve dug through the docs and I can’t seem to find what I’m 
> doing wrong.
> 
> I’ve thrown together a small test script for monit to monitor…
> 
> #!/bin/sh
> 
> FOOPID=/Users/marmel01/Documents/foo.pid
> FOODATES=/tmp/dates
> 
> /bin/echo -n $$ > $FOOPID
> echo 'restarting with '$$' as pid' >> $FOODATES
> ls -l $FOOPID >> $FOODATES
> cat $FOOPID >> $FOODATES
> while true
> do
>     date >> $FOODATES
>     cat $FOOPID >> $FOODATES 2>&1
>     sleep 3
> Done
> 
> 
>  … and a monitrc file to go with it …
> 
> #!/usr/bin/monit -c
> 
> set daemon 10                   # interval between polls, in seconds
> set logfile "/tmp/monitlog.log"
> set pidfile "/tmp/monitpid.pid"
> set statefile "/tmp/monitstate.state"
> set mailserver <REDACTED>
> set alert [email protected] <mailto:[email protected]>
> 
> set httpd port 2812
>     allow localhost
>     allow 10.1.81.0/255.255.255.0
> 
> check process test with pidfile /Users/marmel01/Documents/foo.pid
>       start program = "/Users/marmel01/Documents/monittest.sh"
>       stop program = "/bin/kill $(/bin/cat /Users/marmel01/Documents/foo.pid)”
> 
> However, when I run, while the script seems to be executing perfectly well, 
> monit won’t seem to recognise the fact!
> 
> Here’s an excerpt form monit’s log
> 
> [GMT Nov 19 12:39:30] info     : Monit daemon with PID 75079 awakened
> [GMT Nov 19 12:39:53] error    : 'test' failed to start (exit status -1) -- 
> Program /Users/marmel01/Documents/monittest.sh timed out
> [GMT Nov 19 12:39:53] info     : Awakened by User defined signal 1
> [GMT Nov 19 12:39:53] info     : 'test' monitor action failed
> [GMT Nov 19 12:39:53] error    : 'test' process is not running
> [GMT Nov 19 12:39:53] info     : 'test' trying to restart
> [GMT Nov 19 12:39:53] info     : 'test' start: 
> /Users/marmel01/Documents/monittest.sh
> [GMT Nov 19 12:40:23] error    : 'test' failed to start (exit status -1) -- 
> Program /Users/marmel01/Documents/monittesh.sh timed out
> [GMT Nov 19 12:40:33] error    : 'test' process is not running
> …
> 
> The pid file appears to be where it should be and is readable. I don’t know 
> where to go from here.
> 
> I’m running the latest version of monit on Darwin.
> 
> Any help would be greatly appreciated!
> 
> Mark.
> 
> 
> -- IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Reply via email to