Beispiel #1
0
function rrd_substitute_host_query_data($txt_graph_item, $graph, $graph_item) {
	/* replace host variables in graph elements */
	$txt_graph_item = substitute_host_data($txt_graph_item, '|','|', $graph["host_id"]);

	/* replace query variables in graph elements */
	if (preg_match("/\|query_[a-zA-Z0-9_]+\|/", $txt_graph_item)) {
		/* default to the graph data query information from the graph */
		if (empty($graph_item["local_data_id"])) {
			return substitute_snmp_query_data($txt_graph_item, $graph["host_id"], $graph["snmp_query_id"], $graph["snmp_index"]);
		/* use the data query information from the data source if possible */
		}else{
			$data_local = db_fetch_row("select snmp_index,snmp_query_id,host_id from data_local where id='" . $graph_item["local_data_id"] . "'");
			return substitute_snmp_query_data($txt_graph_item, $data_local["host_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]);
		}
	}else{
		return $txt_graph_item;
	}
}
Beispiel #2
0
function get_script_query_path($args, $script_path, $host_id) {
	global $config;

	include_once($config["library_path"] . "/variables.php");

	/* get any extra arguments that need to be passed to the script */
	if (!empty($args)) {
		$extra_arguments = substitute_host_data($args, "|", "|", $host_id);
	}else{
		$extra_arguments = "";
	}

	/* get a complete path for out target script */
	return substitute_script_query_path($script_path) . " $extra_arguments";
}
Beispiel #3
0
function expand_title($host_id, $snmp_query_id, $snmp_index, $title)
{
    if (strstr($title, '|') && !empty($host_id)) {
        if ($snmp_query_id != '0' && $snmp_index != '') {
            return substitute_snmp_query_data(null_out_substitutions(substitute_host_data($title, '|', '|', $host_id)), $host_id, $snmp_query_id, $snmp_index, read_config_option('max_data_query_field_length'));
        } else {
            return null_out_substitutions(substitute_host_data($title, '|', '|', $host_id));
        }
    } else {
        return null_out_substitutions($title);
    }
}
Beispiel #4
0
function expand_title($host_id, $snmp_query_id, $snmp_index, $title) {
	if ((strstr($title, "|")) && (!empty($host_id))) {
		if (($snmp_query_id != "0") && ($snmp_index != "")) {
			return substitute_snmp_query_data(null_out_substitutions(substitute_host_data($title, "|", "|", $host_id)), $host_id, $snmp_query_id, $snmp_index, read_config_option("max_data_query_field_length"));
		}else{
			return null_out_substitutions(substitute_host_data($title, "|", "|", $host_id));
		}
	}else{
		return null_out_substitutions($title);
	}
}
Beispiel #5
0
function rrd_substitute_host_query_data($txt_graph_item, $graph, $graph_item)
{
    /* replace host variables in graph elements */
    $host_id = 0;
    if (empty($graph["host_id"])) {
        /* if graph has no associated host determine host_id from graph item data source */
        if (!empty($graph_item["local_data_id"])) {
            $host_id = db_fetch_cell("SELECT host_id FROM data_local WHERE id='" . $graph_item["local_data_id"] . "'");
        }
    } else {
        $host_id = $graph["host_id"];
    }
    $txt_graph_item = substitute_host_data($txt_graph_item, '|', '|', $host_id);
    /* replace query variables in graph elements */
    if (preg_match("/\\|query_[a-zA-Z0-9_]+\\|/", $txt_graph_item)) {
        /* default to the graph data query information from the graph */
        if (empty($graph_item["local_data_id"])) {
            $txt_graph_item = substitute_snmp_query_data($txt_graph_item, $graph["host_id"], $graph["snmp_query_id"], $graph["snmp_index"]);
            /* use the data query information from the data source if possible */
        } else {
            $data_local = db_fetch_row("SELECT snmp_index,snmp_query_id,host_id FROM data_local WHERE id='" . $graph_item["local_data_id"] . "'");
            $txt_graph_item = substitute_snmp_query_data($txt_graph_item, $data_local["host_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]);
        }
    }
    /* replace query variables in graph elements */
    if (preg_match("/\\|input_[a-zA-Z0-9_]+\\|/", $txt_graph_item)) {
        return substitute_data_input_data($txt_graph_item, $graph, $graph_item["local_data_id"]);
    }
    return $txt_graph_item;
}