Description of problem: I'm trying to use "monit" to restart certain processes that are otherwise started via "rc" and /etc/init.d, on the event that they exit unexpectedly. The basic setup for this is simple and well-documented; you just add a monit config entry like: check process someservice with pidfile /var/run/someservice.pid start program = "/etc/init.d/someservice start" However, what concerns me a bit is that this essentially bypasses the entire "init" system, and "chkconfig", "service" etc; if I disable the service using chkconfig someservice off or try to force it to stop temporarily via service someservice stop will still try to (re)start it, meaning that the above will have little or no effect. I'd really like to have some simple and direct way to say "restart this process if it goes away, but only if it was enabled in the first place". One way of achieving this might be to (optionally) change the rules for the process test from: If the pidfile does not exist or does not contain the pid number of a running process, monit will call the entry's start method if defined. to If the pidfile does not exist, monit will do nothing. If the pid file exists, but does not contain the pid number of a running process, monit will call the entry's start method if defined. Version-Release number of selected component (if applicable): 4.10.1 How reproducible: Enough said, I think
I also hoped that the following might be used as a workaround: check process someservice with pidfile /var/run/someservice.pid start program = "/etc/init.d/someservice start" depends servicepid check file servicepid /var/run/someservice.pid mode passive The idea being that "someservice" would not be started if it depended on a service that was missing, and couldn't be started. But apparently, the "depends" statement does not work that way - a failure in a prerequisite for a service does not prevent the service itself form being tested or restarted. So I guess you might say that "depends" doesn't set up true dependencies...
(In reply to comment #1) > check process someservice with pidfile /var/run/someservice.pid > start program = "/etc/init.d/someservice start" > depends servicepid > > check file servicepid /var/run/someservice.pid Whoops. Make that "check file servicepid with path /var/run/someservice.pid" > mode passive
Sorry, but I can't really help with this - please contact upstream about the RFE. However, it may be helpful to know that chkconfig creates symlinks in /etc/rc.d/rcX.d for each service you enable. Perhaps chaining a CHECK FILE will help?