Esempio n. 1
0
function get_full_script_path($data_source_id) {
	require_once(CACTI_BASE_PATH . "/lib/sys/variable.php");
	require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php");

	$data_input_type = db_fetch_cell("select data_input_type from data_source where id = $data_source_id");

	/* snmp-actions don't have paths */
	if ($data_input_type != DATA_INPUT_TYPE_SCRIPT) {
		return false;
	}

	$data_source_fields = array_rekey(db_fetch_assoc("select name,value from data_source_field where data_source_id = $data_source_id"), "name", "value");

	if (isset($data_source_fields["script_id"])) {
		$script_path = db_fetch_cell("select input_string from data_input where id = " . $data_source_fields["script_id"]);

		/* exclude the manditory script_id field */
		unset($data_source_fields["script_id"]);

		/* substitute user variables */
		while (list($name, $value) = each($data_source_fields)) {
			$script_path = str_replace("<" . $name . ">", $value, $script_path);
		}

		/* substitute path variables */
		$script_path = substitute_path_variables($script_path);

		/* remove all remaining variables */
		$script_path = preg_replace("/(<[A-Za-z0-9_]+>)+/", "", $script_path);

		return $script_path;
	}
}
Esempio n. 2
0
function api_data_source_path_get($data_source_id, $expand_paths) {
	require_once(CACTI_BASE_PATH . "/lib/sys/variable.php");
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_update.php");

	$current_path = db_fetch_cell("select rrd_path from data_source where id = $data_source_id");

	/* generate a new path if needed */
	if ($current_path == "") {
		$current_path = api_data_source_path_get_update($data_source_id);
	}

	if ($expand_paths == true) {
		return substitute_path_variables($current_path);
	}else{
		return $current_path;
	}
}
Esempio n. 3
0
function api_data_query_script_path_format($script_path) {
	require_once(CACTI_BASE_PATH . "/lib/sys/variable.php");

	/* get a complete path for out target script */
	return substitute_path_variables($script_path);
}