monit-general
[Top][All Lists]
Advanced

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

Re: Config generrator/templating


From: Lutz Mader
Subject: Re: Config generrator/templating
Date: Mon, 17 Jun 2019 21:22:16 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hello David,
I use m4 to generate my Monit config files based on some more or less
complex macro files, like this one.

dnl
dnl Monit configuration file.
dnl Check the Glassfish program status.
dnl
ifdef(`CF_HOMEDIR',`',`define(`CF_HOMEDIR',`syscmd(`printf "%s"
"$HOME"')')')dnl
dnl
ifdef(`CF_HOST',`',`define(`CF_HOST',`syscmd(`printf "%s"
"$(hostname)"')')')dnl
ifdef(`CF_PORT',`',`define(`CF_PORT',`8080')')dnl
ifdef(`CF_APPL',`',`define(`CF_APPL',`domain1')')dnl
ifdef(`CF_SOFTDIR',`',`define(`CF_SOFTDIR',`/usr/local')')dnl
dnl
#
## Check the Glassfish program status.
#
check process Domain1 with matching "CF_SOFTDIR()/.*/bin/java
.*glassfish.jar .*CF_APPL()*"
  start program "CF_HOMEDIR()/monit/scripts/glassfish start" with
timeout 300 seconds
  stop program "CF_HOMEDIR()/monit/scripts/glassfish stop" with timeout
300 seconds
  if failed host CF_HOST() port CF_PORT() then restart
  if 3 restarts within 50 cycles then unmonitor
  group AppDynamics
#

And I create the Monit config file by calling m4 with some additional
names and values.

m4 -DCF_SOFTDIR=/usr/local -DCF_HOMEDIR=/home/glassfish glassfish.m4

#
## Check the Glassfish program status.
#
check process Domain1 with matching "/usr/local/.*/bin/java
.*glassfish.jar .*domain1.*"
  start program "/home/glassfish/monit/scripts/glassfish start" with
timeout 300 seconds
  stop program "/home/glassfish/monit/scripts/glassfish stop" with
timeout 300 seconds
  if failed host macmini.local port 8080 then restart
  if 3 restarts within 50 cycles then unmonitor
  group Glassfish
#

This is my way to configure Monit.
I use some automatic Monit configurations updates based on detecting
application folder updates only.

A suggestion only,
m4 is old, but nice,
Lutz



reply via email to

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