i am trying to figure out how to use monit to get a notification when one of my processes starts to run once again. let me be clear- at first the process is running, stops to run and then runs again. i want to be notified when the process starts running again but i cant find a way to do that with monit. (just to be clear if it stops running i dont want to restart it, but if it starts running i want to be notified) can you help me and tell me how to use monit for my purpose? and if monit is not the answer to my problem can you tell me what is? thanks
Asked
Active
Viewed 850 times
0
-
What have you found about notifications in the monit documentation? – Andrew Schulman Jan 11 '14 at 17:21
-
i didn't find anything.. only sending emails as notification – vivi Jan 12 '14 at 06:19
1 Answers
1
I would implement a notification on PID change. The fact is that if a process is stopped and restarted, it has very very poor chance to have the same PID.
check process myprocess with pidfile /var/run/myprocess.pid
if changed pid then exec "/my/script"
Where /my/script
could be a script that sends an email.
Also, you can use the Monit built-in alert messages :
check process myprocess with pidfile /var/run/myprocess.pid
alert foo@bar only on { pid }
Documentation for Monit alert message
Not tested myself but should work.
Edit : just tested and works !

krisFR
- 13,280
- 4
- 36
- 42
-
isnt there a way where i would "wake up" following an event of a process that starts running? i don't want to wake up periodically.. – vivi Jan 12 '14 at 06:20