How about something like this…
check program server-status with path /usr/local/bin/state.sh
every “5 * * * *"
if status = x then exec /usr/bin/bash -c "/usr/local/bin/foo.sh (x)”
if status = y then exec /usr/bin/bash -c "/usr/local/bin/foo.sh (y)"
‘state.sh” determines the states of your system/application. Monit monitors
this state and then routes to the proper endpoint. In foo.sh you can then put
whatever logic you want to correspond to your exit code. This can be starting,
stopping, pulling from a cluster rotation….
On February 5, 2016 at 5:17:29 AM, Vadym Chepkov ([email protected]) wrote:
It has come to my mind to have two different configs, but I was hoping monit
had a more elegant solution. Thanks.
Cheers,
Vadym
Sent from Android
On Feb 4, 2016 7:47 AM, "Phil Townes" <[email protected]> wrote:
I use two different monit configuration files. One for standby state, and one
for active state.
In the event that it is determined that a standby server is to become active,
the monit configuration file is overwritten with the config file for an
'active' server, and monit is reloaded.
I use a custom script for "should not be running" services in the standby state:
#! /bin/bash
# Look for a service that should be offline
ps -ef | grep -q 'my-service-name-here'
# Return an appropriate exit code
if [ $? -eq 0 ] ; then
echo "Process exists, this is a failure"
exit 1;
else
echo "Process does NOT exist. This is a success."
exit 0;
fi
On 4 February 2016 at 11:52, Vadym Chepkov <[email protected]> wrote:
Hi,
Can somebody give an advice how to implement active/standby configuration using
monit.
There are some services which can't run from multiple locations for various
reasons. To solve this problem, we have a script, which can be used to check if
current location is active or standby via exit code. cron wrapper uses it to
determine if cron job should run or not, for instance.
But how does one tell monit to start/monitor services if server becomes active
and stop, make sure they are not running if server is in standby mode.
This should be applied only to 'volatile' services, not all of them.
Thank you.
Cheers,
Vadym
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general