コード例 #1
0
ファイル: xpddefault.c プロジェクト: bluemutedwisdom/nagios
/* updates host performance data */
int xpddefault_update_host_performance_data(host *hst)
{
	nagios_macros mac;


	/*
	 * 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 (!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 */
	memset(&mac, 0, sizeof(mac));
	grab_host_macros(&mac, hst);

	/* run the performance data command */
	xpddefault_run_host_performance_data_command(&mac, hst);

	/* no more commands to run, so we won't need this any more */
	clear_argv_macros(&mac);

	/* update the performance data file */
	xpddefault_update_host_performance_data_file(&mac, hst);

	/* free() all */
	clear_volatile_macros(&mac);

	return OK;
}
コード例 #2
0
ファイル: perfdata.c プロジェクト: naemon/naemon-core
/* updates host performance data */
int update_host_performance_data(host *hst)
{
	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 host? */
	if (hst->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 (host_perfdata_process_empty_results == FALSE) {
		if (!hst || !hst->perf_data || !*hst->perf_data) {
			return OK;
		}
		if ((!host_perfdata_file_template) && !host_perfdata_command) {
			return OK;
		}
	}

	/* set up macros and get to work */
	memset(&mac, 0, sizeof(mac));
	grab_host_macros_r(&mac, hst);

	/* run the performance data command */
	xpddefault_run_host_performance_data_command(&mac, hst);

	/* no more commands to run, so we won't need this any more */
	clear_argv_macros_r(&mac);

	/* update the performance data file */
	xpddefault_update_host_performance_data_file(&mac, hst);

	/* free() all */
	clear_volatile_macros_r(&mac);

	return OK;
}