void print_result (settings *conf_settings, received_probe *probe , resume *result) { double bandwidth = 0.0, diff = 0.0; char buffer[256]; char *log_file = probe->log_file; if (!probe) return; diff = difftimeval2db(&(probe->start), &(probe->end)); if ((probe->received_total > 0) && (probe->received_packets > 0) && (diff > 0.0)) { bandwidth = (double)(probe->received_total*8)/diff; result->packet_size = probe->received_total/probe->received_packets; result->packet_num = probe->received_packets; result->bytes = probe->received_total; /* double to timeval....*/ double2timeval(bandwidth, &(result->bw_med)); /* timeval - timeval */ difftimeval ( &(probe->start), &(probe->end), &(result->time_med)); result->jitter_med = result->jitter_med/(probe->received_packets - 1); memset (buffer, 0, 256); if (!get_currentDateTime (buffer, 256)) { LOG_FILE (((log_file != NULL) ? log_file : DEFAULT_RECVCONT_BURST_LOGFILE), "[%s]\t%4d\t%4d\t%5d\t%10d\t%12.4f\t%09.6f\n", buffer, conf_settings->recvsock_buffer, probe->received_total/probe->received_packets, probe->received_packets, probe->received_total, bandwidth/1000000, diff); } else { LOG_FILE (((log_file != NULL) ? log_file : DEFAULT_RECVCONT_BURST_LOGFILE), "%4d\t%4d\t%5d\t%10d\t%12.4f\t%09.6f\n", conf_settings->recvsock_buffer, probe->received_total/probe->received_packets, probe->received_packets, probe->received_total, bandwidth/1000000, diff); } } return; }
int read_child_check(char *bufstart, char *bufend, struct timeval * end_time) { char *attribute = NULL; char *attribute2 = NULL; char *attribute3 = NULL; char *error = NULL; char temp_buffer[GM_BUFFERSIZE]; double end_time_d; struct timeval start_time; /* child check number */ if ((attribute=read_multi_attribute(bufstart,bufend,"no")) == NULL) { return 0; } else { /* skip parent check */ if (!strcmp(attribute,"0")) { return 0; } gm_log( GM_LOG_TRACE, "child check: %d\n", atoi(attribute)); } /* service description */ if ((attribute=read_multi_attribute(bufstart,bufend,"name")) == NULL) return 0; mod_gm_opt->service=gm_strdup(attribute); gm_log( GM_LOG_TRACE, "service_description: %s\n", mod_gm_opt->service); /* return code */ if ((attribute=read_multi_attribute(bufstart,bufend,"rc")) == NULL) return 0; mod_gm_opt->return_code=atoi(attribute); gm_log( GM_LOG_TRACE, "mod_gm_opt->return_code: %d\n", mod_gm_opt->return_code); /* runtime */ if ((attribute=read_multi_attribute(bufstart,bufend,"runtime")) == NULL) return 0; end_time_d = timeval2double(end_time); double2timeval(end_time_d - atof(attribute), &start_time); mod_gm_opt->starttime.tv_sec = start_time.tv_sec; mod_gm_opt->starttime.tv_usec = start_time.tv_usec; gm_log( GM_LOG_TRACE, "starttime: %d.%d\n", mod_gm_opt->starttime.tv_sec, mod_gm_opt->starttime.tv_usec); /* end time is the execution time of send_multi itself */ mod_gm_opt->finishtime.tv_sec = end_time->tv_sec; mod_gm_opt->finishtime.tv_usec = end_time->tv_usec; gm_log( GM_LOG_TRACE, "endtime: %d.%d\n", mod_gm_opt->finishtime.tv_sec, mod_gm_opt->finishtime.tv_usec); /* message */ if ((attribute=read_multi_attribute(bufstart,bufend,"output")) == NULL) return 0; /* stderr */ if ((error=read_multi_attribute(bufstart,bufend,"error")) == NULL) { return 0; /* if error found: 'error' -> ' [error]' */ } else if (*error) { *(--error)='['; *(--error)=' '; strcat(error,"]"); } /* performance data with multi headers */ if ((attribute2=read_multi_attribute(bufstart,bufend,"performance")) == NULL) { snprintf( temp_buffer, sizeof( temp_buffer )-1, "%s%s", decode_xml(attribute), decode_xml(error)); } else if ((attribute3=read_multi_attribute(bufstart,bufend,"pplugin")) == NULL) { return 0; } else { attribute2 = trim(attribute2); attribute2 = decode_xml(attribute2); /* do we have a single quote performance label? then single quote the whole multi header */ if (*attribute2 == '\'') { attribute2++; snprintf( temp_buffer, sizeof( temp_buffer )-1, "%s%s|\'%s::%s::%s", decode_xml(attribute), decode_xml(error), mod_gm_opt->service, decode_xml(attribute3), decode_xml(attribute2)); /* normal header without single quotes */ } else { snprintf( temp_buffer, sizeof( temp_buffer )-1, "%s%s|%s::%s::%s", decode_xml(attribute), decode_xml(error), mod_gm_opt->service, decode_xml(attribute3), decode_xml(attribute2)); } } mod_gm_opt->message=gm_strdup(temp_buffer); gm_log( GM_LOG_TRACE, "mod_gm_opt->message: %s\n", mod_gm_opt->message); return 1; }