I'm having trouble with monit. I have setup monitoring with monit. However, I'm having trouble with a check for the process running. If the process is not running, i want to run an specific script that will create a pagerduty alert.
My Monit file looks like this:
check process "myapp" matching "myapp"
start program = "/usr/local/myapp start"
stop program = "/usr/local/myapp stop"
if does not exist then exec "/bin/bash pagerduty_script 'MyApp Down' trigger"
The pagerduty_script
is just a wrapper that takes two arguments "string event"
and action trigger
The script works. I've tested in terminal and it runs fine. events are actually created in pagerduty. However, it doesn't seem like monit is actually running it even though no process is running:
ps -ef | grep myapp
vagrant 23950 23136 0 17:40 pts/0 00:00:00 grep --color=auto myapp
sudo monit status:
Process 'myapp'
status Execution failed
monitoring status Monitored
data collected Tue, 16 Sep 2014 17:40:11
I don't understand why it works on the console, but monit doesn't actually generate the event. Any help would be greatly appreciated!
if does not exist then exec "/usr/local/bin/pagerduty_script 'MyApp Down' trigger"
But this doesn't work. I'm not sure what other things i could try.man monit
? That is basically all the docs there are for monit. The documentation the monit web site is just the most recent version of the man file.start program
at your script, or a script that sends your alert, then tries to re-start your program?