0

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

vivi
  • 1
  • 1
  • 2

1 Answers1

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
  • 12,830
  • 3
  • 31
  • 40
  • 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