[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: don' t skip hostchecks when servicechecks are disabled (Stephen Gran) #778

git at icinga.org git at icinga.org
Tue Sep 21 14:54:47 CEST 2010


Module: icinga-core
Branch: mfriedrich/core
Commit: 7bfd6520a55a7e7125dd642268ad9cd8b372429a
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=7bfd6520a55a7e7125dd642268ad9cd8b372429a

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Tue Sep 21 13:39:21 2010 +0200

don't skip hostchecks when servicechecks are disabled (Stephen Gran) #778

please check the issues for detailed information.
code comment has been added too explaining old and new logic.

refs #581
fixes #778

---

 Changelog     |    1 +
 THANKS        |    1 +
 base/events.c |   26 +++++++++++++++++++++++++-
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index e50035e..a998942 100644
--- a/Changelog
+++ b/Changelog
@@ -27,6 +27,7 @@ FIXES
 * core: fix for retaining host display name and alias, as well as service display name (Folkert van Heusden)
 * core: fix format errors for logging eventhandlers (Guillaume Rousse)
 * core: remove program update checks as scheduled timed events, not written to status/retention.dat anymore
+* core: don't skip hostchecks when servicechecks are disabled (Stephen Gran) #778
 
 * classic ui: update jquery for multiple cmds dropdown, resolve conflicts with pnp
 * classic ui: fix delay sorting of comments/downtimes (Ton Voon)
diff --git a/THANKS b/THANKS
index 40c77cd..05ec3d2 100644
--- a/THANKS
+++ b/THANKS
@@ -108,6 +108,7 @@ in various ways.  If we missed your name, let us know.
 * David Glick
 * Mark Goldfinch
 * Jeffrey Goldschrafe
+* Stephen Gran
 * Jan Grant
 * Matthew Grant
 * Martin Green
diff --git a/base/events.c b/base/events.c
index e969a7f..f118ab8 100644
--- a/base/events.c
+++ b/base/events.c
@@ -1164,6 +1164,24 @@ int event_execution_loop(void){
 				my_free(temp_event);
 		        }
 
+		/* 21-09-2010 NOTE MF:
+			The logic on low priority events just as host and service checks work liks this:
+			Set run_event=TRUE on looping start, check if next event is a serviecheck. If matched,
+			check for several things, most important for disabled checks. If those are disabled,
+			set run_event=FALSE (this flag will be checked at the end). The servicecheck event
+			will be removed from the eventlist.
+			Same goes for the hostcheck events, and afterwards, run_event is checked and no matter
+			if service or host check event, it gets executed as a timed event, if run_event==TRUE.
+
+			Previous code (21-09-2010) had a logical AND operation, servicecheck and hostcheck events
+			could have been tested within one looping. If servicecheck was disabled, run_event=FALSE,
+			and removed from event queue resulted in next event = hostcheck, which was matched by the
+			2nd IF - also having run_event set to FALSE, causing the hostcheck being skipped too.
+			By changing this to a logical OR operation, IF ... ELSE IF ..., only one check can be
+			matched throughout a single looping and run_event is responsible for only one event at a
+			time - service OR host check event.
+		*/
+
 		/* handle low priority events */
 		else if(event_list_low!=NULL && (current_time>=event_list_low->run_time)){
 
@@ -1176,6 +1194,8 @@ int event_execution_loop(void){
 
 				temp_service=(service *)event_list_low->event_data;
 
+				log_debug_info(DEBUGL_EVENTS|DEBUGL_CHECKS,1,"Run a few checks before executing a service check for '%s'.\n", temp_service->description);
+
 				/* don't run a service check if we're already maxed out on the number of parallel service checks...  */
 				if(max_parallel_service_checks!=0 && (currently_running_service_checks >= max_parallel_service_checks)){
 
@@ -1204,6 +1224,7 @@ int event_execution_loop(void){
 
 					/* remove the service check from the event queue and reschedule it for a later time */
 					/* 12/20/05 since event was not executed, it needs to be remove()'ed to maintain sync with event broker modules */
+					log_debug_info(DEBUGL_EVENTS|DEBUGL_CHECKS,1,"Skip event, removing service '%s' from list.\n", temp_service->description);
 					temp_event=event_list_low;
 					remove_event(temp_event,&event_list_low,&event_list_low_tail);
 					/*
@@ -1231,10 +1252,12 @@ int event_execution_loop(void){
 			        }
 
 			/* run a few checks before executing a host check... */
-			if(event_list_low->event_type==EVENT_HOST_CHECK){
+			else if(event_list_low->event_type==EVENT_HOST_CHECK){
 
 				temp_host=(host *)event_list_low->event_data;
 
+				log_debug_info(DEBUGL_EVENTS|DEBUGL_CHECKS,1,"Run a few checks before executing a host check for '%s'.\n", temp_host->name);
+
 				/* don't run a host check if active checks are disabled */
 				if(execute_host_checks==FALSE){
 
@@ -1252,6 +1275,7 @@ int event_execution_loop(void){
 
 					/* remove the host check from the event queue and reschedule it for a later time */
 					/* 12/20/05 since event was not executed, it needs to be remove()'ed to maintain sync with event broker modules */
+					log_debug_info(DEBUGL_EVENTS|DEBUGL_CHECKS,1,"Skip event, removing host '%s' from list.\n", temp_host->name);
 					temp_event=event_list_low;
 					remove_event(temp_event,&event_list_low,&event_list_low_tail);
 					/*





More information about the icinga-checkins mailing list