Here's the patch I promised to allow cyclic networks, where host A is
the parent of B and B is the parent of A. It was originally developed
against 2.7, then checked against 3.0a1.
Please let me know if having cycles in the network topology breaks any
third-party tools, and I'll see if I can provide patches for them too.
Peter.
diff -r -U 3 --minimal nagios-3.0a1/base/checks.c develop/nagios-3.0a1/base/checks.c
--- nagios-3.0a1/base/checks.c 2007-03-01 18:19:15.000000000 +0000
+++ develop/nagios-3.0a1/base/checks.c 2007-03-21 10:45:08.000000000 +0000
@@ -1844,6 +1844,7 @@
/* reset latency, since on-demand checks have none */
hst->latency=0.0;
+ unmark_all_hosts(CHECKED_HOSTS_SET);
/* check route to the host (propagate problems and recoveries both up and down the tree) */
result=check_host(hst,PROPAGATE_TO_PARENT_HOSTS | PROPAGATE_TO_CHILD_HOSTS,check_options);
@@ -1997,6 +1998,10 @@
printf("check_host() start\n");
#endif
+ if (host_is_marked(hst, CHECKED_HOSTS_SET)) {
+ return hst->current_state;
+ }
+ mark_host(hst, CHECKED_HOSTS_SET);
/* ADDED 06/20/2006 EG */
/* bail out if signal encountered */
if(sigrestart==TRUE || sigshutdown==TRUE)
@@ -2179,9 +2184,9 @@
/* check the parent host, assume its up if we can't find it, use the parent host's "old" status if we shouldn't propagate */
if(parent_host==NULL)
parent_result=HOST_UP;
- else if(propagation_options & PROPAGATE_TO_PARENT_HOSTS)
- parent_result=check_host(parent_host,PROPAGATE_TO_PARENT_HOSTS,check_options);
- else
+ else if(propagation_options & PROPAGATE_TO_PARENT_HOSTS) {
+ parent_result=check_host(parent_host,PROPAGATE_TO_PARENT_HOSTS,check_options);
+ } else
parent_result=parent_host->current_state;
/* if this parent host was up, the route is okay */
diff -r -U 3 --minimal nagios-3.0a1/base/config.c develop/nagios-3.0a1/base/config.c
--- nagios-3.0a1/base/config.c 2007-02-16 19:04:11.000000000 +0000
+++ develop/nagios-3.0a1/base/config.c 2007-03-21 13:46:16.000000000 +0000
@@ -3164,38 +3164,6 @@
/********************************************/
- /* check for circular paths between hosts */
- /********************************************/
- if(verify_config==TRUE)
- printf("Checking for circular paths between hosts...\n");
-
- /* check routes between all hosts */
- found=FALSE;
- result=OK;
- for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
-
- /* clear checked flag for all hosts */
- for(temp_host2=host_list;temp_host2!=NULL;temp_host2=temp_host2->next)
- temp_host2->circular_path_checked=FALSE;
-
- found=check_for_circular_host_path(temp_host,temp_host);
- if(found==TRUE){
- asprintf(&temp_buffer,"Error: There is a circular parent/child path that exists for host '%s'!",temp_host->name);
- write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE);
- my_free((void **)&temp_buffer);
- result=ERROR;
- }
- }
- if(result==ERROR)
- errors++;
-
-#ifdef DEBUG1
- printf("\tCompleted circular path checks\n");
-#endif
-
-
-
- /********************************************/
/* check for circular dependencies */
/********************************************/
if(verify_config==TRUE)
diff -r -U 3 --minimal nagios-3.0a1/cgi/outages.c develop/nagios-3.0a1/cgi/outages.c
--- nagios-3.0a1/cgi/outages.c 2006-03-21 21:38:10.000000000 +0000
+++ develop/nagios-3.0a1/cgi/outages.c 2007-03-21 10:45:11.683849000 +0000
@@ -571,13 +571,16 @@
/* calculates network outage effect of a particular host being down or unreachable */
-void calculate_outage_effect_of_host(host *hst, int *affected_hosts, int *affected_services){
+static void calculate_outage_effect_of_host_rec(host *hst, int *affected_hosts, int *affected_services){
int total_child_hosts_affected=0;
int total_child_services_affected=0;
int temp_child_hosts_affected=0;
int temp_child_services_affected=0;
host *temp_host;
+ if (host_is_marked(hst, CALC_OUTAGE_SET))
+ return;
+ mark_host(hst, CALC_OUTAGE_SET);
/* find all child
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]