[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

monit from init.d script

From: kgardenia42
Subject: monit from init.d script
Date: Thu, 26 Jan 2012 16:39:59 -0800

Hi list,

I need some advice/pointers.  I have what I believe to be a pretty
normal scenario but I can't seem to figure out the "monit way" to do

I have a service (lets call it foo) which I historically have started
with an init.d script as follows:

 service start foo

I'd like to monitor that service with monit.

This is my draft monit confg:

check process foo with pidfile /var/run/foo/
 start program = "/etc/init.d/foo restart" with timeout 60 seconds
 stop program  = "/etc/init.d/foo stop"
 if 3 restarts within 5 cycles then timeout
 group foo

That all works fine .. until I do "service foo stop".   It seems that
(quite reasonably) monit didn't realize I had explicitly stopped foo
and so eventually decides something went wrong and restarted it.  So
how can I tell monit that I stoppd on purpose?  From what I read, and
please correct me if I missed something, then it seems the right way
to do this is to do "monit stop foo".

My problem is that for historical reasons I need to have users
interact with the service using "service <cmd> foo" rather than "monit
<cmd> foo".  Changing to the latter is a big deal.  I'd like monit
being in the mix to be transparent to users.  monit may even be an
optional extra in some cases so I don't want monit commands ingrained
in the user workflows (it is of course fine for my init.d scrpit to do
monit calls behind the scenes where appropriate).    Is there any
common pattern in this case?

My next thought was that I should add "monit unmonitor foo" and "monit
monitor foo" into my legacy init.d script in the stop/start hooks so
that monitor knows when I stopped on purpose.  The problem here is
that if monit is in its 120 second initial "not receiving any
commands" mode then if I were to "service stop foo" in that time
window then monit wouldn't know about it.

So taking a step back - what is the *right way* to do what I'm
describing here?  I am clearly going against the grain here with monit
somehow so I need some guidance on how to do it correctly.  I am most
likely just "missing the point" in some very obvious way and just need
steered on to the right path.

I'd be grateful for any advice.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]