monit-general
[Top][All Lists]
Advanced

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

Re: A way to invoke multiple actions...


From: Martin Pala
Subject: Re: A way to invoke multiple actions...
Date: Mon, 29 Jan 2007 19:56:39 +0100
User-agent: Thunderbird 1.5.0.9 (X11/20061222)

Maybe you can use the port test in combination with rate control and exec action, for exampple:

--8<--
  check host mytomcat with address 127.0.0.1
if failed port 8080 for 5 cycles then exec "/usr/local/bin/maintenance-mode.sh on" else if recovered for 10 cycles then exec "/usr/local/bin/maintenance-mode.sh off" if failed port 8080 for 20 cycles then exec "/usr/bin/monit restart tomcat" if failed port 8080 for 30 cycles then exec "/usr/bin/monit stop tomcat"
--8<--


Martin


Jason L. Buberel wrote:
First, just wanted to say 'great job' to the monit developers. I've now got it deployed on all of the servers behind http://www.altosresearch.com/ and it has been doing a great job.

As I discover more and more services I would like monit to take care of for me, I ran into the following scenario that I'm not sure how to configure:

1. I have an apache -> tomcat -> postgres dependency chain defined and working nicely.

2. I have a script available that will switch apache into 'maintenance mode' which I use when the site is down for maintenance. It simply redirects all requests to a single static maintenance display (http://www.altosresearch.com/maintenance/index.html).

What I would like to have happen is that when the 'tomcat' process is timed-out by monit (the max # of restart attempts is exceeded) that an alert is sent AND a script is executed:

check process tomcat with pidfile /opt/tomcat/temp/tomcat.pid
       alert address@hidden on { timeout }
       start program = "/etc/init.d/tomcat start"
       stop program =  "/etc/init.d/tomcat stop"
       if 5 restarts within 5 cycles
            then timeout
       if 5 restarts within 5 cycles
            then exec "/usr/local/bin/maintenance-mode.sh on"
       depends on postgres

And in a perfect world, I would love to be able to have monit automatically invoke the reversal script ('maintenance-mode.sh off') when tomcat recovers (becomes monitored again).

Are either of my two configuration scenarios possible? Essentially what I am looking to do is have monit execute one or more scripts based on a state change to a monitored service ('exec "some-script.sh" when service foobar is monitored' -or- 'exec "some-script.sh" when service apache is timedout').

Many thanks for any suggestions,
jason



------------------------------------------------------------------------

--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

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