In monit, you can use a matching string for processes that do not have a PID. Using the example of a process named "myprocessname",
check process myprocessname
matching "myprocessname"
start program = "/etc/init.d/myproccessname start"
stop program = "/usr/bin/killall myprocessname"
if cpu usage > 95% for 10 cycles then restart
Maybe if you check to see if CPU load is at a certain level for 10 monitoring cycles (of 30-seconds each), then restart or kill, that could be an option. Or you could use monit's timestamp testing on a file related to the process.
Monit only checks the first process matched by the string. If you have any way to refine the pattern to be more unique, you'll have more success. From the monit procmatch output...
[root@abc ~]# monit procmatch dbc
List of processes matching pattern "dbc":
------------------------------------------
/ppro/dbcfs/dbcfsrun 10.2.2.7 9586 dbcfs.cfg 9584:1 -ssl -sport
dbc DMHOST start cron
dbc
dbc JOBMAN start cron
dbc
dbc
/ppro/dbcfs/dbcfs -y
------------------------------------------
Total matches: 7
WARNING: multiple processes matched the pattern. The check is FIRST-MATCH based, please refine the pattern
Best Answer
This should be doable using a short shell script, and program status testing. Something like
with a shell script like: