[icinga-checkins] icinga.org: icinga-core/next: * core: notifications: Create contact list after eventbroker callbacks (Andreas Ericsson) #2110

git at icinga.org git at icinga.org
Sun Feb 5 14:12:44 CET 2012


Module: icinga-core
Branch: next
Commit: 78db2dc5c4309d05794c5535a249f3a5b69f1585
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=78db2dc5c4309d05794c5535a249f3a5b69f1585

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Fri Jan 27 12:53:47 2012 +0100

* core: notifications: Create contact list after eventbroker callbacks (Andreas Ericsson) #2110

moving the notification contact list creation *after*
sending the neb callback to event brokers that notification
was started will allow such modules to take care of their
own notification logic without having to take care about
the list now floating in memory.

refs #2110

---

 Changelog            |    3 ++
 base/notifications.c |   56 +++++++++++++++++++++++++-------------------------
 2 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/Changelog b/Changelog
index 994df89..c71c18f 100644
--- a/Changelog
+++ b/Changelog
@@ -7,12 +7,15 @@ Thanks to all contributers, testers and developers. Please read AUTHORS and THAN
 1.7.0 - XX/YY/2012
 
 ENHANCEMENTS
+* core: notifications: Create contact list after eventbroker callbacks (Andreas Ericsson) #2110
 
 FIXES
 * core: Plug some macro leaks triggered when sending notifications (Andreas Ericsson) #2109
 * install: Fix notification template installation (Todd Zullinger) #2235
 
 CHANGES
+* neb api: move creation of notification contact list AFTER event broker callback NEBTYPE_NOTIFICATION_START #2110
+	** allows neb modules to cancel/override notification list creation on notification start
 * debug: set debug_verbosity=2 by default
 
 
diff --git a/base/notifications.c b/base/notifications.c
index 722228b..e36fd36 100644
--- a/base/notifications.c
+++ b/base/notifications.c
@@ -134,6 +134,20 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat
 
 	/* create the contact notification list for this service */
 
+#ifdef USE_EVENT_BROKER
+	/* send data to event broker */
+	end_time.tv_sec = 0L;
+	end_time.tv_usec = 0L;
+	neb_result = broker_notification_data(NEBTYPE_NOTIFICATION_START, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_NOTIFICATION, type, start_time, end_time, (void *)svc, not_author, not_data, escalated, 0, NULL);
+	if (NEBERROR_CALLBACKCANCEL == neb_result) {
+		free_notification_list();
+		return ERROR;
+	} else if (NEBERROR_CALLBACKOVERRIDE == neb_result) {
+		free_notification_list();
+		return OK;
+	}
+#endif
+
 	/* 2011-10-21 MF:  
 	   check viability before adding a contact
 	   to the notification list, requires type
@@ -151,20 +165,6 @@ int service_notification(service *svc, int type, char *not_author, char *not_dat
 	*/
 	create_notification_list_from_service(&mac, svc, options, &escalated, type);
 
-#ifdef USE_EVENT_BROKER
-	/* send data to event broker */
-	end_time.tv_sec = 0L;
-	end_time.tv_usec = 0L;
-	neb_result = broker_notification_data(NEBTYPE_NOTIFICATION_START, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_NOTIFICATION, type, start_time, end_time, (void *)svc, not_author, not_data, escalated, 0, NULL);
-	if (NEBERROR_CALLBACKCANCEL == neb_result) {
-		free_notification_list();
-		return ERROR;
-	} else if (NEBERROR_CALLBACKOVERRIDE == neb_result) {
-		free_notification_list();
-		return OK;
-	}
-#endif
-
 	/* XXX: crazy indent */
 	/* we have contacts to notify... */
 	if (notification_list != NULL) {
@@ -1316,6 +1316,20 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
 
 	/* create the contact notification list for this host */
 
+#ifdef USE_EVENT_BROKER
+	/* send data to event broker */
+	end_time.tv_sec = 0L;
+	end_time.tv_usec = 0L;
+	neb_result = broker_notification_data(NEBTYPE_NOTIFICATION_START, NEBFLAG_NONE, NEBATTR_NONE, HOST_NOTIFICATION, type, start_time, end_time, (void *)hst, not_author, not_data, escalated, 0, NULL);
+	if (NEBERROR_CALLBACKCANCEL == neb_result) {
+		free_notification_list();
+		return ERROR;
+	} else if (NEBERROR_CALLBACKOVERRIDE == neb_result) {
+		free_notification_list();
+		return OK;
+	}
+#endif
+
         /* 2011-10-21 MF:  
            check viability before adding a contact
            to the notification list, requires type
@@ -1333,20 +1347,6 @@ int host_notification(host *hst, int type, char *not_author, char *not_data, int
         */
 	create_notification_list_from_host(&mac, hst, options, &escalated, type);
 
-#ifdef USE_EVENT_BROKER
-	/* send data to event broker */
-	end_time.tv_sec = 0L;
-	end_time.tv_usec = 0L;
-	neb_result = broker_notification_data(NEBTYPE_NOTIFICATION_START, NEBFLAG_NONE, NEBATTR_NONE, HOST_NOTIFICATION, type, start_time, end_time, (void *)hst, not_author, not_data, escalated, 0, NULL);
-	if (NEBERROR_CALLBACKCANCEL == neb_result) {
-		free_notification_list();
-		return ERROR;
-	} else if (NEBERROR_CALLBACKOVERRIDE == neb_result) {
-		free_notification_list();
-		return OK;
-	}
-#endif
-
 	/* XXX: crazy indent */
 	/* there are contacts to be notified... */
 	if (notification_list != NULL) {





More information about the icinga-checkins mailing list