diff -ur nagios-2.9.original/base/commands.c nagios-2.9/base/commands.c --- nagios-2.9.original/base/commands.c 2007-03-05 17:34:39.000000000 +0000 +++ nagios-2.9/base/commands.c 2007-09-14 17:25:37.000000000 +0100 @@ -2005,6 +2005,7 @@ /* save the plugin output */ strncpy(temp_plugin_output,output,MAX_PLUGINOUTPUT_LENGTH-1); temp_plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; + /* printf("\nfull=#%s#\n", output); */ @@ -2051,41 +2052,37 @@ if(temp_host->latency<0.0) temp_host->latency=0.0; - /* check for empty plugin output */ - if(!strcmp(temp_plugin_output,"")) - strcpy(temp_plugin_output,"(No Information Returned From Host Check)"); - /* first part of plugin output (up to pipe) is status info */ - temp_ptr=strtok(temp_plugin_output,"|\n"); + temp_ptr=strpbrk(temp_plugin_output,"|\n"); + + /* If there is, cut string short */ + if(temp_ptr!=NULL){ + *temp_ptr = '\x0'; + } - /* make sure the plugin output isn't NULL */ - if(temp_ptr==NULL){ + strip(temp_plugin_output); + if(!strcmp(temp_plugin_output,"")){ strncpy(temp_host->plugin_output,"(No output returned from host check)",MAX_PLUGINOUTPUT_LENGTH-1); temp_host->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; - } - + } else{ + strncpy(temp_host->plugin_output,temp_plugin_output,MAX_PLUGINOUTPUT_LENGTH-1); + temp_host->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; + } + /* printf("output=#%s#\n", temp_host->plugin_output); */ - strip(temp_ptr); - if(!strcmp(temp_ptr,"")){ - strncpy(temp_host->plugin_output,"(No output returned from host check)",MAX_PLUGINOUTPUT_LENGTH-1); - temp_host->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; - } - else{ - strncpy(temp_host->plugin_output,temp_ptr,MAX_PLUGINOUTPUT_LENGTH-1); - temp_host->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; - } - } - - /* second part of plugin output (after pipe) is performance data (which may or may not exist) */ - temp_ptr=strtok(NULL,"\n"); + /* Get original output to calculate perfdata, as might have been amended above */ + strncpy(temp_plugin_output,output,MAX_PLUGINOUTPUT_LENGTH-1); + temp_plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; - /* grab performance data if we found it available */ - if(temp_ptr!=NULL){ + temp_ptr=strchr(temp_plugin_output,'|'); + if(temp_ptr!=NULL) { + temp_ptr++; /* Move to next character - TODO: a linefeed should be checked, but passivechecks can't return these */ strip(temp_ptr); strncpy(temp_host->perf_data,temp_ptr,MAX_PLUGINOUTPUT_LENGTH-1); temp_host->perf_data[MAX_PLUGINOUTPUT_LENGTH-1]='\x0'; } + /* printf("perfdata=#%s#\n", temp_host->perf_data); */ /* replace semicolons in plugin output (but not performance data) with colons */ temp_ptr=temp_host->plugin_output;