0

I am trying to figure out a way to get a notification when one of my processes starts to run once again (i have tried monitoring the proc file but didn't succeed, monit doesn't handle getting the same pid and runs periodically). any ideas?

4 Answers 4

1

In my opinion, your first idea about using Monit was the best approach and is the more robust.

i have tried monitoring the proc file but didn't succeed

Tell us where you are stuck, we could help. Monit is fully able to do that. Maybe you have a misconfiguration of Monit somewhere.

monit doesn't handle getting the same pid

Right, but you should not be worried about that. The way Linux systems manage processes, you will never get the same PID as the previous one.

and (Monit) runs periodically

Right. Monit has a default polling interval of 120 seconds. If this lantency is not suitable for you, you can reduce the polling interval by changing the value of set daemon n (where n is a number in seconds - default 120) parameter in config file.

1
  • i have tried monitoring the proc with "inotify" and didn't succeed. (didn't try this with monit because didn't know how)
    – vivi
    Jan 13, 2014 at 4:57
1

maybe something completely different. A simple wrapper.

write a bash script put in on place of original binary

#!/bin/bash

# put here commands to notify You
# optional commands to redirect fd to original processs if needed

exec /path/to/original/binary

Your questions has not much details about what exactly You expect but this would do the job.

1
  • just to be clear- each time a program restarts i want to start running a simple program that prints that one of the programs restarted.
    – vivi
    Jan 13, 2014 at 4:59
1

You can be notified of process-related kernel events via Netlink. See here for example code.

0

you can write a program that get the processes list and parse this list and detect new processes. then add a "http xml value sensor" to your monitoring software(cacti, ...) and check your program results.

http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .