[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: monit monitor.h p.y validate.c
From: |
Jan-Henrik Haukeland |
Subject: |
Re: monit monitor.h p.y validate.c |
Date: |
10 Nov 2002 18:29:18 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Civil Service) |
Rory Toma <address@hidden> writes:
> Log message:
> Make the dependency not matter on the ordering in monitrc,
> things should only get validated once.
> Please test.
Looks like you nearly nailed it :-) Except, that the start order is
reversed. If you have a dependency A->B then A is always started
before B allthough it should be the other way around I think. I have
the following dependency:
apache -> sendmail
and get this when I run ./monit with no processes started
[CET Nov 10 17:42:26] 'apache' is not running.
[CET Nov 10 17:42:26] start: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:42:26] start: (sendmail) /home/hauk/bin/tst
Also if I run 'monit stop' stop sendmail is called twice:
[CET Nov 10 17:41:09] stop: (sendmail) /home/hauk/bin/tst
[CET Nov 10 17:41:09] stop: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:41:09] stop: (sendmail) /home/hauk/bin/tst
Calling 'monit restart' doesn't work properly, it depend in the order
I have written the entries into the monitrc file:
If I have:
check sendmail (..)
check apache (..) depend sendmail
I get this, i.e. on-off-on for sendmail:
[CET Nov 10 17:45:47] stop: (sendmail) /home/hauk/bin/tst
[CET Nov 10 17:45:51] stop: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:45:57] start: (sendmail) /home/hauk/bin/tst
[CET Nov 10 17:45:59] stop: (sendmail) /home/hauk/bin/tst
[CET Nov 10 17:46:01] start: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:46:01] start: (sendmail) /home/hauk/bin/tst
and if I have this order
check apache (..) depend sendmail
check sendmail (..)
I get this which is slightly better, the stop order is fine but the
start order is reversed.
[CET Nov 10 17:45:47] stop: (sendmail) /home/hauk/bin/tst
[CET Nov 10 17:45:51] stop: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:46:01] start: (apache) /usr/local/apache/bin/http
[CET Nov 10 17:46:01] start: (sendmail) /home/hauk/bin/tst
In the depend validate function I think you must test for loops and
validate the process when you backtrack to get the correct start/stop
order. Something like this (only a draft and not tested, and
p->visited should be set to FALSE in p.y when monit starts):
void validate() {
..
for (p= processlist; p; p= p->next) {
if(p->visited)
continue;
else {
if (p->dependantlist != NULL) {
depend_validate(p);
} else {
if(!do_not_validate(p))
do_validate(p);
}
}
}
/* Reset the visit markers */
for(processlist) set all processes p->visited= FALSE;
}
/**
* Walk the process-list and validate each process
*/
void depend_validate(Process_T p) {
p->visited= TRUE;
if(p->dependantlist) {
Process_T dp;
Dependant_T d;
/* Now check dependants */
for (d= p->dependantlist; d; d= p->dependantlist->next) {
if(d->visited) continue;
d->visited= TRUE; // The dependant object must also have a visited
marker
dp= get_process(d->dependant);
if(dp->visited) {
error("Got depenency loop"); exit(1);
}
depend_validate(dp);
}
}
/* This is executed when backtracking from the recursive call stack */
if(!do_not_validate(p))
do_validate(p);
}
--
Jan-Henrik Haukeland