[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditional service start or stop
From: |
Martin Pala |
Subject: |
Re: conditional service start or stop |
Date: |
Tue, 13 Dec 2011 14:42:17 +0100 |
Hi,
yes, you can use the exc action to call monit CLI command, for example:
--8<--
check process p1 with path …
start program = …
stop program = …
group main
if 3 restarts within 5 cycles then exec "/bin/bash -c '/usr/bin/monit -g
main stop && /usr/bin/monit -g backup start'"
check process p2 with path …
start program = …
stop program = …
group backup
mode manual
--8<--
=>
1.) the service group called "main" contains service "p1" and is started by
default
2.) the service group called "backup" contains service "p2" and is not started
unless requested by user ("mode manual") - that request is triggered via the
exec action when the process p1 restarted too frequently without effect.
Note that the monitoring mode is persistent across restarts => if you recovered
the service and want to return it back, you should do: "monit -g backup stop &&
monit -g main start"
Regards,
Martin
On Dec 12, 2011, at 1:36 PM, Lawrence, Wayne wrote:
> Hi,
>
> I was wondering if there was a way to configure monit to start a different
> service based on a failure event.
>
> I have 2 configs for httpd on my server one for the website and one for
> maintenance.
>
> If the main website configuration failed to restart for example 3 times in 5
> cycles I would like to stop the services that are connected to it and bring
> up the maintenance configuration instead. Ideally i would like to stop a
> group of services as defined in the monitrc and start another.
>
> I know you can do exec statements the achieve this but was wondering if
> calling monit commands from within the monitrc would be problematic or if it
> there was a simple way within moint to achieve this.
>
> Regards
>
> Wayne
>
>
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general