[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: core: log a debug message when a neb module overrides a check

git at icinga.org git at icinga.org
Fri Mar 8 18:52:10 CET 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri Mar  8 18:09:19 2013 +0100

core: log a debug message when a neb module overrides a check

---

 base/checks.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/base/checks.c b/base/checks.c
index f0ee03d..e8f1c72 100644
--- a/base/checks.c
+++ b/base/checks.c
@@ -545,6 +545,12 @@ int run_async_service_check(service *svc, int check_options, double latency, int
 	/* send data to event broker */
 	neb_result = broker_service_check(NEBTYPE_SERVICECHECK_ASYNC_PRECHECK, NEBFLAG_NONE, NEBATTR_NONE, svc, SERVICE_CHECK_ACTIVE, start_time, end_time, svc->service_check_command, svc->latency, 0.0, 0, FALSE, 0, NULL, NULL);
 
+    if (neb_result == NEBERROR_CALLBACKCANCEL || neb_result == NEBERROR_CALLBACKOVERRIDE) {
+        log_debug_info(DEBUGL_CHECKS, 0, "Check of service '%s' on host '%s' was %s by a module\n",
+                svc->description, svc->host_name,
+                neb_result == NEBERROR_CALLBACKCANCEL ? "cancelled" : "overridden");
+    }
+
 	/* neb module wants to cancel the service check - the check will be rescheduled for a later time by the scheduling logic */
 	if (neb_result == NEBERROR_CALLBACKCANCEL) {
 		if (preferred_time)
@@ -2896,14 +2902,20 @@ int execute_sync_host_check_3x(host *hst) {
 	/* send data to event broker */
 	neb_result = broker_host_check(NEBTYPE_HOSTCHECK_SYNC_PRECHECK, NEBFLAG_NONE, NEBATTR_NONE, hst, HOST_CHECK_ACTIVE, hst->current_state, hst->state_type, start_time, end_time, hst->host_check_command, hst->latency, 0.0, host_check_timeout, FALSE, 0, NULL, NULL, NULL, NULL, NULL);
 
-	/* neb module wants to cancel the host check - return the current state of the host */
-	if (neb_result == NEBERROR_CALLBACKCANCEL)
+	/*
+     * neb module wants to cancel/override the host check
+     * then return the current state of the host
+     * NOTE: if a module does this, it must check the status of the host
+     * and populate the data structures BEFORE it returns from the callback!
+     */
+	if (neb_result == NEBERROR_CALLBACKCANCEL || neb_result == NEBERROR_CALLBACKOVERRIDE) {
+        log_debug_info(DEBUGL_CHECKS, 0, "Check of host '%s' was %s by a module. Returning %d\n",
+                hst->name,
+                neb_result == NEBERROR_CALLBACKCANCEL ? "cancelled" : "overridden",
+                hst->current_state);
 		return hst->current_state;
+    }
 
-	/* neb module wants to override the host check - perhaps it will check the host itself */
-	/* NOTE: if a module does this, it must check the status of the host and populate the data structures BEFORE it returns from the callback! */
-	if (neb_result == NEBERROR_CALLBACKOVERRIDE)
-		return hst->current_state;
 #endif
 
 	/* grab the host macros */





More information about the icinga-checkins mailing list