[Nagios-checkins] SF.net SVN: nagios:[2026] nagioscore/trunk/base/notifications.c

ageric at users.sourceforge.net ageric at users.sourceforge.net
Thu Aug 2 00:42:00 UTC 2012


Revision: 2026
          http://nagios.svn.sourceforge.net/nagios/?rev=2026&view=rev
Author:   ageric
Date:     2012-08-02 00:42:00 +0000 (Thu, 02 Aug 2012)
Log Message:
-----------
core: Send notifications through workers

Notifications take a significant amount of time, most of which used to
stall Nagios completely. With this change, we get rid of that latency-
inducing behaviour and paw off notifications to be run by one of our
command execution workers.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Modified Paths:
--------------
    nagioscore/trunk/base/notifications.c

Modified: nagioscore/trunk/base/notifications.c
===================================================================
--- nagioscore/trunk/base/notifications.c	2012-07-18 10:27:26 UTC (rev 2025)
+++ nagioscore/trunk/base/notifications.c	2012-08-02 00:42:00 UTC (rev 2026)
@@ -31,6 +31,7 @@
 #include "../include/nagios.h"
 #include "../include/broker.h"
 #include "../include/neberrors.h"
+#include "../include/workers.h"
 
 extern notification    *notification_list;
 extern contact         *contact_list;
@@ -713,14 +714,11 @@
 	char *processed_command = NULL;
 	char *temp_buffer = NULL;
 	char *processed_buffer = NULL;
-	int early_timeout = FALSE;
-	double exectime;
 	struct timeval start_time, end_time;
 	struct timeval method_start_time, method_end_time;
 	int macro_options = STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS;
 	int neb_result;
 
-
 	log_debug_info(DEBUGL_FUNCTIONS, 0, "notify_contact_of_service()\n");
 
 	log_debug_info(DEBUGL_NOTIFICATIONS, 2, "** Notifying contact '%s'\n", cntct->name);
@@ -817,13 +815,8 @@
 			}
 
 		/* run the notification command */
-		my_system_r(mac, processed_command, notification_timeout, &early_timeout, &exectime, NULL, 0);
+		wproc_notify(cntct->name, svc->host_name, svc->description, processed_command, mac);
 
-		/* check to see if the notification command timed out */
-		if(early_timeout == TRUE) {
-			logit(NSLOG_SERVICE_NOTIFICATION | NSLOG_RUNTIME_WARNING, TRUE, "Warning: Contact '%s' service notification command '%s' timed out after %d seconds\n", cntct->name, processed_command, notification_timeout);
-			}
-
 		/* free memory */
 		my_free(command_name);
 		my_free(processed_command);
@@ -1649,8 +1642,6 @@
 	char *processed_buffer = NULL;
 	char *raw_command = NULL;
 	char *processed_command = NULL;
-	int early_timeout = FALSE;
-	double exectime;
 	struct timeval start_time;
 	struct timeval end_time;
 	struct timeval method_start_time;
@@ -1755,12 +1746,9 @@
 			}
 
 		/* run the notification command */
-		my_system_r(mac, processed_command, notification_timeout, &early_timeout, &exectime, NULL, 0);
+		wproc_notify(cntct->name, hst->name, NULL, processed_command, mac);
 
-		/* check to see if the notification timed out */
-		if(early_timeout == TRUE) {
-			logit(NSLOG_HOST_NOTIFICATION | NSLOG_RUNTIME_WARNING, TRUE, "Warning: Contact '%s' host notification command '%s' timed out after %d seconds\n", cntct->name, processed_command, notification_timeout);
-			}
+		/* @todo Handle nebmod stuff when getting results from workers */
 
 		/* free memory */
 		my_free(command_name);

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Nagios-commits mailing list