[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Odd monit configuration help...
From: |
Jan-Henrik Haukeland |
Subject: |
RE: Odd monit configuration help... |
Date: |
Thu, 4 Nov 2004 20:33:00 +0100 |
> 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?
>From the top off my head I think I would do something like this. Note this is
really just a draft without much "fine thinking" behind it.
1) Choose a high level scripting language for the script, such as Perl or
Python
2) Load from a common file or better from an URL a property file listing all
the services you have on all machines. The format of the file can be:
ssh = /etc/monit.d/ssh
smtp = /etc/monit.d/smtp
httpd = /etc/monit.d/httpd
.....
Load the properties into a hash-table.
3) Get a list of the services that should run on the machine. Use as previously
suggested chkconfig --list or similar. If you have different os'es you could do
something like this (in pseudo code):
OS= uname;
switch(OS) {
case Linux:
Use 'chkconfig --list' and build a list of the
services that should run. Map the name of the
service to the key in the hash-table mentioned in 2).
case FreeBSD:
Use something else to get the service list and do the
same as with the Linux case.
}
4) a) Open the file /etc/monitrc in write mode.
b) for each service in the service list built in 3) do;
lookup the service in the hashtable
if (found)
print to /etc/monitrc "include" + hastable{service};
else
log an error, a service is found in the machine which is
not in our global service list.
c) Close /etc/monitrc
This should give you a /etc/monitrc file with the content that look something
like this depending on the services that *should* run on the machine:
include /etc/monit.d/ssh
include /etc/monit.d/httpd
5) The script outlined in 1-4 above should be called as follows. If monit is
started from inittab, add a last line to the script where monit is started
using exec and replace the inittab entry for monit with a call to the script
instead. If monit is called from sysinit rc-scripts, edit /etc/init.d/rc.monit
and add a call to the script before monit is started.
Just my $0.02