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!
Best Answer
I have been facing a similar problem and I figured out that the pagerduty script creates a temp file for the trigger and if this is file is modified not more than 4 hours ago, it doesn't re-trigger the alert.
It may have been the case that when you executed from the console, you have already create a temp file. You can verify this by deleting the temp file just before monit is expected to trigger an alert.
The other option is to use different unique event type to just test it out.