/* updates service performance data */ int update_service_performance_data(service *svc) { nagios_macros mac; /* should we be processing performance data for anything? */ if (process_performance_data == FALSE) return OK; /* should we process performance data for this service? */ if (svc->process_performance_data == FALSE) return OK; /* * 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 (service_perfdata_process_empty_results == FALSE) { if (!svc || !svc->perf_data || !*svc->perf_data) { return OK; } if ((!service_perfdata_file_template) && !service_perfdata_command) { return OK; } } /* * we know we've got some work to do, so grab the necessary * macros and get busy */ memset(&mac, 0, sizeof(mac)); grab_service_macros_r(&mac, svc); /* run the performance data command */ xpddefault_run_service_performance_data_command(&mac, svc); /* get rid of used memory we won't need anymore */ clear_argv_macros_r(&mac); /* update the performance data file */ xpddefault_update_service_performance_data_file(&mac, svc); /* now free() it all */ clear_volatile_macros_r(&mac); return OK; }
/* updates service performance data */ int xpddefault_update_service_performance_data(service *svc) { nagios_macros mac; 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 */ 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; } /* * we know we've got some work to do, so grab the necessary * macros and get busy */ memset(&mac, 0, sizeof(mac)); hst = find_host(svc->host_name); grab_host_macros(&mac, hst); grab_service_macros(&mac, svc); /* run the performance data command */ xpddefault_run_service_performance_data_command(&mac, svc); /* get rid of used memory we won't need anymore */ clear_argv_macros(&mac); /* update the performance data file */ xpddefault_update_service_performance_data_file(&mac, svc); /* now free() it all */ clear_volatile_macros(&mac); return OK; }