monit-general
[Top][All Lists]
Advanced

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

Re: Odd monit configuration help...


From: Mark Ferlatte
Subject: Re: Odd monit configuration help...
Date: Thu, 4 Nov 2004 07:43:24 -0800
User-agent: Mutt/1.4.2.1i

Jan-Henrik Haukeland said on Thu, Nov 04, 2004 at 12:06:55AM +0100:
> On Wed, 2004-11-03 at 22:16, Christopher P. Lindsey wrote:
> 
> > I'd say your best bet is to use service-specific configuration
> > files shared across all servers, like one for ntpd, one for sendmail,
> > etc.
> > 
> > Then you could write a quick script to create /etc/monitrc before starting
> > monit.  So if the server detects that it needs to run ntpd and sendmail,
> > it might generate a monitrc file that looks like
> > 
> >    INCLUDE "/usr/local/etc/monit/sendmail.monitrc"
> >    INCLUDE "/usr/local/etc/monit/ntpd.monitrc"
> 
> That was a clever suggestion! As far as I can see this is a fine
> workaround. If Mark or anyone else does write such a script and it's
> general enough it would be highly appreciated if it was shared with the
> rest of the mailing list and we would absolutely consider adding it to
> monit's contrib directory.

Well, the funny thing is I am already using per service config files that are
shared... my monitrc just looks like this:

set logfile = syslog
set alert address@hidden
set httpd port 2812 and use address localhost
        allow localhost
        allow monit:monit
include /etc/monit/monit.d/*

and then monit.d contains files like this:

/etc/monit/monit.d/ssh:
check ssh.sshd with pidfile /var/run/sshd.pid
        start program "/etc/init.d/ssh start"
        stop program "/etc/init.d/ssh stop"
        if failed port 22 protocol ssh then restart
        if 5 restarts within 5 cycles then timeout

check file ssh.etc.ssh.sshd_config with path /etc/ssh/sshd_config
        if timestamp changed then
                exec "/etc/init.d/ssh reload"

check file ssh.usr.sbin.sshd with path /usr/sbin/sshd
        if timestamp changed then
                exec "/etc/init.d/ssh restart"

Okay.  So, what do folks think about this solution:

A script parses the monit config fragements looking for pidfile statements.
For each pidfile, check if it exists and is running.  If true, symlink from
monit.enabled/servicename -> monit.d/servicename.

Then, change the include to be

include /etc/monit/monit.enabled/*

Can anyone see a major problem with that approach?

M

Attachment: pgpVScTXRG4vx.pgp
Description: PGP signature


reply via email to

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