Bug 602603 - RFE: Monitor a "service" process only if it was already started
Summary: RFE: Monitor a "service" process only if it was already started
Status: CLOSED CANTFIX
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: monit
Version: el5
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Stewart Adam
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-10 09:49 UTC by Toralf
Modified: 2010-06-21 19:05 UTC (History)
1 user (show)

(edit)
Clone Of:
(edit)
Last Closed: 2010-06-21 19:05:46 UTC


Attachments (Terms of Use)

Description Toralf 2010-06-10 09:49:01 UTC
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

Comment 1 Toralf 2010-06-10 12:43:48 UTC
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...

Comment 2 Toralf 2010-06-10 12:47:06 UTC
(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

Comment 3 Stewart Adam 2010-06-21 19:05:46 UTC
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?


Note You need to log in before you can comment on or make changes to this bug.