[icinga-checkins] icinga.org: icinga-core/master: core: re-allow perfdata with empty results being put on perfdata channel, disable via opt-in cfg option #1413

git at icinga.org git at icinga.org
Sat Apr 30 21:33:38 CEST 2011


Module: icinga-core
Branch: master
Commit: 465f5aa1710f60e41db012ba7915e66fdfdce06e
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=465f5aa1710f60e41db012ba7915e66fdfdce06e

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Thu Apr 28 17:24:41 2011 +0200

core: re-allow perfdata with empty results being put on perfdata channel, disable via opt-in cfg option #1413

refs #1413

---

 Changelog                   |    2 ++
 sample-config/icinga.cfg.in |   12 ++++++++++++
 xdata/xpddefault.c          |   37 +++++++++++++++++++++++++++----------
 xdata/xpddefault.h          |    3 ++-
 4 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/Changelog b/Changelog
index 8b30c38..dfb7ca8 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,8 @@ Icinga 1.4.x Change Log
 1.4.0 - 11/05/2011
 
 ENHANCEMENTS
+* core: re-allow perfdata with empty results being put on perfdata channel, disable via opt-in cfg option #1413
+
 * classic ui: merged reading of logfiles into one function. It's easier now to add enhancements. #972
 * classic ui: Adding some more icons to showlog.cgi #1239
 * classic ui: adding entry time of comments in tooltip's in status.cgi #1244
diff --git a/sample-config/icinga.cfg.in b/sample-config/icinga.cfg.in
index c1edac7..500a00a 100644
--- a/sample-config/icinga.cfg.in
+++ b/sample-config/icinga.cfg.in
@@ -957,6 +957,18 @@ process_performance_data=0
 #service_perfdata_file_processing_command=process-service-perfdata-file
 
 
+# HOST AND SERVICE PERFORMANCE DATA PROCESS EMPTY RESULTS
+# THese options determine wether the core will process empty perfdata
+# results or not. This is needed for distributed monitoring, and intentionally
+# turned on by default.
+# If you don't require empty perfdata - saving some cpu cycles
+# on unwanted macro calculation - you can turn that off. Be careful!
+# Values: 1 = enable, 0 = disable
+
+#host_perfdata_process_empty_results=1
+#service_perfdata_process_empty_results=1
+
+
 
 # ALLOW EMPTY HOSTGROUP ASSIGMENT FOR SERVICES
 # This boolean option determines whether services assigned to empty
diff --git a/xdata/xpddefault.c b/xdata/xpddefault.c
index 0ad9c39..7a58c51 100644
--- a/xdata/xpddefault.c
+++ b/xdata/xpddefault.c
@@ -64,6 +64,9 @@ char    *xpddefault_service_perfdata_file_processing_command=NULL;
 command *xpddefault_host_perfdata_file_processing_command_ptr=NULL;
 command *xpddefault_service_perfdata_file_processing_command_ptr=NULL;
 
+int     xpddefault_host_perfdata_process_empty_results=DEFAULT_HOST_PERFDATA_PROCESS_EMPTY_RESULTS;
+int     xpddefault_service_perfdata_process_empty_results=DEFAULT_SERVICE_PERFDATA_PROCESS_EMPTY_RESULTS;
+
 FILE    *xpddefault_host_perfdata_fp=NULL;
 FILE    *xpddefault_service_perfdata_fp=NULL;
 int     xpddefault_host_perfdata_fd=-1;
@@ -193,6 +196,12 @@ int xpddefault_grab_config_directives(char *input){
 	else if(!strcmp(varname,"service_perfdata_file_processing_command"))
 		xpddefault_service_perfdata_file_processing_command=(char *)strdup(varvalue);
 
+	else if(!strcmp(varname,"host_perfdata_process_empty_results"))
+		xpddefault_host_perfdata_process_empty_results=(atoi(varvalue)>0)?TRUE:FALSE;
+
+	else if(!strcmp(varname,"service_perfdata_process_empty_results"))
+		xpddefault_service_perfdata_process_empty_results=(atoi(varvalue)>0)?TRUE:FALSE;
+
 	/* free memory */
 	my_free(varname);
 	my_free(varvalue);
@@ -386,12 +395,16 @@ int xpddefault_update_service_performance_data(service *svc){
 	/*
 	 * bail early if we've got nothing to do so we don't spend a lot
 	 * of time calculating macros that never get used
+	 * on distributed setups, empty perfdata results are required, so
+	 * only drop out if demanded via configs.
 	 */
-	if (!svc || !svc->perf_data || !*svc->perf_data) {
-		return OK;
-	}
-	if ((!xpddefault_service_perfdata_fp || !xpddefault_service_perfdata_file_template) && !xpddefault_service_perfdata_command) {
-		return OK;
+	if(xpddefault_service_perfdata_process_empty_results==FALSE){
+		if (!svc || !svc->perf_data || !*svc->perf_data){
+			return OK;
+		}
+		if ((!xpddefault_service_perfdata_fp || !xpddefault_service_perfdata_file_template) && !xpddefault_service_perfdata_command){
+			return OK;
+		}
 	}
 
 	/*
@@ -427,12 +440,16 @@ int xpddefault_update_host_performance_data(host *hst){
 	/*
 	 * bail early if we've got nothing to do so we don't spend a lot
 	 * of time calculating macros that never get used
+	 * on distributed setups, empty perfdata results are required, so
+	 * only drop out if demanded via configs.
 	 */
-	if (!hst || !hst->perf_data || !*hst->perf_data) {
-		return OK;
-	}
-	if ((!xpddefault_host_perfdata_fp || !xpddefault_host_perfdata_file_template) && !xpddefault_host_perfdata_command) {
-		return OK;
+        if(xpddefault_host_perfdata_process_empty_results==FALSE){
+		if (!hst || !hst->perf_data || !*hst->perf_data) {
+			return OK;
+		}
+		if ((!xpddefault_host_perfdata_fp || !xpddefault_host_perfdata_file_template) && !xpddefault_host_perfdata_command) {
+			return OK;
+		}
 	}
 
 	/* set up macros and get to work */
diff --git a/xdata/xpddefault.h b/xdata/xpddefault.h
index ab0fd44..0c6b087 100644
--- a/xdata/xpddefault.h
+++ b/xdata/xpddefault.h
@@ -32,7 +32,8 @@
 #define DEFAULT_HOST_PERFDATA_FILE_TEMPLATE "[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$"
 #define DEFAULT_SERVICE_PERFDATA_FILE_TEMPLATE "[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$"
 
-
+#define DEFAULT_HOST_PERFDATA_PROCESS_EMPTY_RESULTS 	1
+#define DEFAULT_SERVICE_PERFDATA_PROCESS_EMPTY_RESULTS 	1
 
 int xpddefault_initialize_performance_data(char *);
 int xpddefault_cleanup_performance_data(char *);





More information about the icinga-checkins mailing list