--=-0N29YBV7Kg3WVh461DOh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Another small fix for a case when
process_performance_data=1
host_perfdata_file=/tmp/foo.log
service_perfdata_file=/tmp/foo.log
are defined in nagios.cfg but no host_perfdata_file_template or
service_perfdata_file_template are defined.
Rather than dropping the attempt to record performance data when things
are wrongly configured (as it looks like the idea of the current code is
to do) a default value for both could be defined.
Patch included for either option against latest cvs.
--
Matthew Kent
http://magoazul.com
--=-0N29YBV7Kg3WVh461DOh
Content-Disposition: attachment; filename=nagios-2.0a1-perf_fix.patch
Content-Type: text/x-patch; name=nagios-2.0a1-perf_fix.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit
diff -u3r nagios_orig/xdata/xpddefault.c nagios/xdata/xpddefault.c
--- nagios_orig/xdata/xpddefault.c 2004-09-02 20:53:00.000000000 -0400
+++ nagios/xdata/xpddefault.c 2004-09-22 21:34:37.000000000 -0400
@@ -205,10 +214,15 @@
FILE *fp;
int error=FALSE;
+
/* open the config file for reading */
fp=fopen(config_file,"r");
- if(fp==NULL)
+ if(fp==NULL){
+#ifdef DEBUG1
+ printf("Error: Cannot open main configuration file '%s' for reading!\n",config_file);
+#endif
return ERROR;
+ }
/* read in all lines from the config file */
for(fgets(input_buffer,sizeof(input_buffer)-1,fp);!feof(fp);fgets(input_buffer,sizeof(input_buffer)-1,fp)){
@@ -584,7 +598,7 @@
int result=OK;
/* we don't have a file to write to*/
- if(xpddefault_service_perfdata_fp==NULL)
+ if(xpddefault_service_perfdata_fp==NULL || xpddefault_service_perfdata_file_template==NULL)
return OK;
/* find the associated host */
@@ -626,7 +640,7 @@
int result=OK;
/* we don't have a host perfdata file */
- if(xpddefault_host_perfdata_fp==NULL)
+ if(xpddefault_host_perfdata_fp==NULL || xpddefault_host_perfdata_file_template==NULL)
return OK;
/* update host macros */
--=-0N29YBV7Kg3WVh461DOh
Content-Disposition: attachment; filename=nagios-2.0a1-perf_fix_defaults.patch
Content-Type: text/x-patch; name=nagios-2.0a1-perf_fix_defaults.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit
diff -u3r nagios_orig/include/config.h.in nagios/include/config.h.in
--- nagios_orig/include/config.h.in 2003-10-28 01:04:31.000000000 -0500
+++ nagios/include/config.h.in 2004-09-22 20:34:19.000000000 -0400
@@ -283,3 +283,9 @@
#endif
#endif
+
+/* default perfdata_file_template */
+#ifdef USE_XPDDEFAULT
+#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$"
+#endif
diff -u3r nagios_orig/xdata/xpddefault.c nagios/xdata/xpddefault.c
--- nagios_orig/xdata/xpddefault.c 2004-09-02 20:53:00.000000000 -0400
+++ nagios/xdata/xpddefault.c 2004-09-22 21:09:25.000000000 -0400
@@ -96,6 +96,13 @@
/* grab config info from main config file */
xpddefault_grab_config_info(config_file);
+
+ /* make sure we have our templates */
+ if(xpddefault_host_perfdata_file_template==NULL)
+ xpddefault_host_perfdata_file_template=strdup(DEFAULT_HOST_PERFDATA_FILE_TEMPLATE);
+ if(xpddefault_service_perfdata_file_template==NULL)
+ xpddefault_service_perfdata_file_template=strdup(DEFAULT_SERVICE_PERFDATA_FILE_TEMPLATE);
+
/* process special chars in templates */
xpddefault_preprocess_file_templates(xpddefault_host_perfdata_file_template);
xpddefault_preprocess_file_templates(xpddefault_service_perfdata_file_template);
@@ -205,10 +214,15 @@
FILE *fp;
int error=FALSE;
+
/* open the config file for reading */
fp=fopen(config_file,"r");
- if(fp==NULL)
+ if(fp==NULL){
+#ifdef DEBUG1
+ printf("Error: Cannot open main configuration file '%s' for reading!\n",config_file);
+#endif
return ERROR;
+ }
/* read in all lines from the config file */
for(fgets(input_buffer,sizeof(input_buffer)-1,fp);!feof(fp);fgets(input_buffer,sizeof(input
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]