• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_data_source_item_name函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_data_source_item_name函数的典型用法代码示例。如果您正苦于以下问题:PHP get_data_source_item_name函数的具体用法?PHP get_data_source_item_name怎么用?PHP get_data_source_item_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_data_source_item_name函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: rrdtool_function_tune

function rrdtool_function_tune($rrd_tune_array) {
	global $config;

	include($config["include_path"] . "/global_arrays.php");

	$data_source_name = get_data_source_item_name($rrd_tune_array["data_source_id"]);
	$data_source_type = $data_source_types{$rrd_tune_array["data-source-type"]};
	$data_source_path = get_data_source_path($rrd_tune_array["data_source_id"], true);

	if ($rrd_tune_array["heartbeat"] != "") {
		$rrd_tune .= " --heartbeat $data_source_name:" . $rrd_tune_array["heartbeat"];
	}

	if ($rrd_tune_array["minimum"] != "") {
		$rrd_tune .= " --minimum $data_source_name:" . $rrd_tune_array["minimum"];
	}

	if ($rrd_tune_array["maximum"] != "") {
		$rrd_tune .= " --maximum $data_source_name:" . $rrd_tune_array["maximum"];
	}

	if ($rrd_tune_array["data-source-type"] != "") {
		$rrd_tune .= " --data-source-type $data_source_name:" . $data_source_type;
	}

	if ($rrd_tune_array["data-source-rename"] != "") {
		$rrd_tune .= " --data-source-rename $data_source_name:" . $rrd_tune_array["data-source-rename"];
	}

	if ($rrd_tune != "") {
		if (file_exists($data_source_path) == true) {
			$fp = popen(read_config_option("path_rrdtool") . " tune $data_source_path $rrd_tune", "r");
			pclose($fp);

			if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_DEBUG) {
				cacti_log("CACTI2RRD: " . read_config_option("path_rrdtool") . " tune $data_source_path $rrd_tune");
			}
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:40,代码来源:rrd.php


示例2: boost_rrdtool_function_create

function boost_rrdtool_function_create($local_data_id, $initial_time, $show_source)
{
    global $config;
    include $config["include_path"] . "/global_arrays.php";
    $data_source_path = get_data_source_path($local_data_id, TRUE);
    /* ok, if that passes lets check to make sure an rra does not already
    	exist, the last thing we want to do is overright data! */
    if ($show_source != TRUE) {
        if (file_exists($data_source_path) == TRUE) {
            return -1;
        }
    }
    /* the first thing we must do is make sure there is at least one
    	rra associated with this data source... *
    	UPDATE: As of version 0.6.6, we are splitting this up into two
    	SQL strings because of the multiple DS per RRD support. This is
    	not a big deal however since this function gets called once per
    	data source */
    $rras = db_fetch_assoc("select\r\n\t\tdata_template_data.rrd_step,\r\n\t\trra.x_files_factor,\r\n\t\trra.steps,\r\n\t\trra.rows,\r\n\t\trra_cf.consolidation_function_id,\r\n\t\t(rra.rows*rra.steps) as rra_order\r\n\t\tfrom data_template_data\r\n\t\tleft join data_template_data_rra on (data_template_data.id=data_template_data_rra.data_template_data_id)\r\n\t\tleft join rra on (data_template_data_rra.rra_id=rra.id)\r\n\t\tleft join rra_cf on (rra.id=rra_cf.rra_id)\r\n\t\twhere data_template_data.local_data_id={$local_data_id}\r\n\t\tand (rra.steps is not null or rra.rows is not null)\r\n\t\torder by rra_cf.consolidation_function_id,rra_order");
    /* if we find that this DS has no RRA associated; get out.  This would
     * indicate that a data sources has been deleted
     */
    if (sizeof($rras) <= 0) {
        return FALSE;
    }
    /* back off the initial time to allow updates */
    $initial_time -= 300;
    /* create the "--step" line */
    $create_ds = RRD_NL . "--start " . $initial_time . " --step " . $rras[0]["rrd_step"] . " " . RRD_NL;
    /* query the data sources to be used in this .rrd file */
    $data_sources = db_fetch_assoc("SELECT\r\n\t\tdata_template_rrd.id,\r\n\t\tdata_template_rrd.rrd_heartbeat,\r\n\t\tdata_template_rrd.rrd_minimum,\r\n\t\tdata_template_rrd.rrd_maximum,\r\n\t\tdata_template_rrd.data_source_type_id\r\n\t\tFROM data_template_rrd\r\n\t\tWHERE data_template_rrd.local_data_id={$local_data_id}\r\n\t\tORDER BY local_data_template_rrd_id");
    /* ONLY make a new DS entry if:
    	- There is multiple data sources and this item is not the main one.
    	- There is only one data source (then use it) */
    if (sizeof($data_sources) > 0) {
        foreach ($data_sources as $data_source) {
            /* use the cacti ds name by default or the user defined one, if entered */
            $data_source_name = get_data_source_item_name($data_source["id"]);
            if (empty($data_source["rrd_maximum"])) {
                /* in case no maximum is given, use "Undef" value */
                $data_source["rrd_maximum"] = "U";
            } elseif (strpos($data_source["rrd_maximum"], "|query_") !== false) {
                if ($data_source["rrd_maximum"] == "|query_ifSpeed|" || $data_source["rrd_maximum"] == "|query_ifHighSpeed|") {
                    $highSpeed = db_fetch_cell("SELECT field_value\r\n\t\t\t\t\tFROM host_snmp_cache\r\n\t\t\t\t\tWHERE host_id=" . $data_local["host_id"] . "\r\n\t\t\t\t\tAND snmp_query_id=" . $data_local["snmp_query_id"] . "\r\n\t\t\t\t\tAND snmp_index='" . $data_local["snmp_index"] . "'\r\n\t\t\t\t\tAND field_name='ifHighSpeed'");
                    if (!empty($highSpeed)) {
                        $data_source["rrd_maximum"] = $highSpeed * 1000000;
                    } else {
                        $data_source["rrd_maximum"] = substitute_snmp_query_data("|query_ifSpeed|", $data_local["host_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]);
                    }
                } else {
                    $data_source["rrd_maximum"] = substitute_snmp_query_data($data_source["rrd_maximum"], $data_local["host_id"], $data_local["snmp_query_id"], $data_local["snmp_index"]);
                }
            } elseif ($data_source["rrd_maximum"] != "U" && (int) $data_source["rrd_maximum"] <= (int) $data_source["rrd_minimum"]) {
                /* max > min required, but take care of an "Undef" value */
                $data_source["rrd_maximum"] = (int) $data_source["rrd_minimum"] + 1;
            }
            /* min==max==0 won't work with rrdtool */
            if ($data_source["rrd_minimum"] == 0 && $data_source["rrd_maximum"] == 0) {
                $data_source["rrd_maximum"] = "U";
            }
            $create_ds .= "DS:{$data_source_name}:" . $data_source_types[$data_source["data_source_type_id"]] . ":" . $data_source["rrd_heartbeat"] . ":" . $data_source["rrd_minimum"] . ":" . $data_source["rrd_maximum"] . RRD_NL;
        }
    }
    $create_rra = "";
    /* loop through each available RRA for this DS */
    foreach ($rras as $rra) {
        $create_rra .= "RRA:" . $consolidation_functions[$rra["consolidation_function_id"]] . ":" . $rra["x_files_factor"] . ":" . $rra["steps"] . ":" . $rra["rows"] . RRD_NL;
    }
    /* check for structured path configuration, if in place verify directory
    	   exists and if not create it.
    	 */
    if (read_config_option("extended_paths") == "on") {
        if (!is_dir(dirname($data_source_path))) {
            if (mkdir(dirname($data_source_path), 0775)) {
                if ($config["cacti_server_os"] != "win32") {
                    $owner_id = fileowner($config["rra_path"]);
                    $group_id = filegroup($config["rra_path"]);
                    if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
                        /* permissions set ok */
                    } else {
                        cacti_log("ERROR: Unable to set directory permissions for '" . dirname($data_source_path) . "'", FALSE);
                    }
                }
            } else {
                cacti_log("ERROR: Unable to create directory '" . dirname($data_source_path) . "'", FALSE);
            }
        }
    }
    if ($show_source == TRUE) {
        return read_config_option("path_rrdtool") . " create" . RRD_NL . "{$data_source_path}{$create_ds}{$create_rra}";
    } else {
        return boost_rrdtool_execute("create {$data_source_path} {$create_ds}{$create_rra}", FALSE, RRDTOOL_OUTPUT_STDOUT);
    }
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:94,代码来源:setup.php


示例3: update_poller_cache

function update_poller_cache($local_data_id, $commit = false) {
	global $config;
	require_once(CACTI_BASE_PATH . "/include/data_input/data_input_constants.php");
	include_once(CACTI_BASE_PATH . "/lib/data_query.php");
	include_once(CACTI_BASE_PATH . "/lib/api_poller.php");

	$poller_items = array();

	$data_input = db_fetch_row("select
		data_input.id,
		data_input.type_id,
		data_template_data.id as data_template_data_id,
		data_template_data.data_template_id,
		data_template_data.active,
		data_template_data.rrd_step
		from (data_template_data,data_input)
		where data_template_data.data_input_id=data_input.id
		and data_template_data.local_data_id=$local_data_id");

	$data_source = db_fetch_row("select device_id,snmp_query_id,snmp_index from data_local where id=$local_data_id");

	/* we have to perform some additional sql queries if this is a "query" */
	if (($data_input["type_id"] == DATA_INPUT_TYPE_SNMP_QUERY) ||
		($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT_QUERY) ||
		($data_input["type_id"] == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER)){
		$field = data_query_field_list($data_input["data_template_data_id"]);

		if (strlen($field["output_type"])) {
			$output_type_sql = "and snmp_query_graph_rrd.snmp_query_graph_id=" . $field["output_type"];
		}else{
			$output_type_sql = "";
		}

		$outputs = db_fetch_assoc("select
			snmp_query_graph_rrd.snmp_field_name,
			data_template_rrd.id as data_template_rrd_id
			from (snmp_query_graph_rrd,data_template_rrd)
			where snmp_query_graph_rrd.data_template_rrd_id=data_template_rrd.local_data_template_rrd_id
			$output_type_sql
			and snmp_query_graph_rrd.data_template_id=" . $data_input["data_template_id"] . "
			and data_template_rrd.local_data_id=$local_data_id");
	}

	if ($data_input["active"] == CHECKED) {
		if (($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT) || ($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER)) { /* script */
			/* fall back to non-script server actions if the user is running a version of php older than 4.3 */
			if (($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) && (function_exists("proc_open"))) {
				$action = POLLER_ACTION_SCRIPT_PHP;
				$script_path = get_full_script_path($local_data_id);
			}else if (($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) && (!function_exists("proc_open"))) {
				$action = POLLER_ACTION_SCRIPT;
				$script_path = read_config_option("path_php_binary") . " -q " . get_full_script_path($local_data_id);
			}else{
				$action = POLLER_ACTION_SCRIPT;
				$script_path = get_full_script_path($local_data_id);
			}

			$num_output_fields = sizeof(db_fetch_assoc("select id from data_input_fields where data_input_id=" . $data_input["id"] . " and input_output='out' and update_rra='on'"));

			if ($num_output_fields == 1) {
				$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_id=$local_data_id");
				$data_source_item_name = get_data_source_item_name($data_template_rrd_id);
			}else{
				$data_source_item_name = "";
			}

			$poller_items[] = api_poller_cache_item_add($data_source["device_id"], array(), $local_data_id, $data_input["rrd_step"], $action, $data_source_item_name, 1, addslashes($script_path));
		}else if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP) { /* snmp */
			/* get the device override fields */
			$data_template_id = db_fetch_cell("SELECT data_template_id FROM data_template_data WHERE local_data_id=$local_data_id");

			/* get device fields first */
			$device_fields = array_rekey(db_fetch_assoc("SELECT
				data_input_fields.type_code,
				data_input_data.value
				FROM data_input_fields
				LEFT JOIN data_input_data
				ON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_input["data_template_data_id"] . ")
				WHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname'))
				AND data_input_data.value != ''"), "type_code", "value");

			$data_template_fields = array_rekey(db_fetch_assoc("SELECT
				data_input_fields.type_code,
				data_input_data.value
				FROM data_input_fields
				LEFT JOIN data_input_data
				ON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=$data_template_id)
				WHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname'))
				AND data_template_data_id=$data_template_id
				AND data_input_data.value != ''"), "type_code", "value");

			if (sizeof($device_fields)) {
				if (sizeof($data_template_fields)) {
				foreach($data_template_fields as $key => $value) {
					if (!isset($device_fields[$key])) {
						$device_fields[$key] = $value;
					}
				}
				}
			} elseif (sizeof($data_template_fields)) {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:utility.php


示例4: boost_rrdtool_function_create

function boost_rrdtool_function_create($local_data_id, $initial_time, $show_source)
{
    global $config;
    include $config['include_path'] . '/global_arrays.php';
    $data_source_path = get_data_source_path($local_data_id, true);
    /* ok, if that passes lets check to make sure an rra does not already
    	exist, the last thing we want to do is overright data! */
    if ($show_source != true) {
        if (file_exists($data_source_path) == true) {
            return -1;
        }
    }
    /* the first thing we must do is make sure there is at least one
    	rra associated with this data source... *
    	UPDATE: As of version 0.6.6, we are splitting this up into two
    	SQL strings because of the multiple DS per RRD support. This is
    	not a big deal however since this function gets called once per
    	data source */
    $rras = db_fetch_assoc_prepared('SELECT
		data_template_data.rrd_step,
		rra.x_files_factor,
		rra.steps,
		rra.rows,
		rra_cf.consolidation_function_id,
		(rra.rows * rra.steps) AS rra_order
		FROM data_template_data
		LEFT JOIN data_template_data_rra ON (data_template_data.id = data_template_data_rra.data_template_data_id)
		LEFT JOIN rra ON (data_template_data_rra.rra_id = rra.id)
		LEFT JOIN rra_cf ON (rra.id = rra_cf.rra_id)
		WHERE data_template_data.local_data_id = ?
		AND (rra.steps is not null OR rra.rows is not null)
		ORDER BY rra_cf.consolidation_function_id, rra_order', array($local_data_id));
    /* if we find that this DS has no RRA associated; get out.  This would
     * indicate that a data sources has been deleted
     */
    if (sizeof($rras) <= 0) {
        return false;
    }
    /* back off the initial time to allow updates */
    $initial_time -= 300;
    /* create the "--step" line */
    $create_ds = RRD_NL . '--start ' . $initial_time . ' --step ' . $rras[0]['rrd_step'] . ' ' . RRD_NL;
    /* query the data sources to be used in this .rrd file */
    $data_sources = db_fetch_assoc_prepared('SELECT
		data_template_rrd.id,
		data_template_rrd.rrd_heartbeat,
		data_template_rrd.rrd_minimum,
		data_template_rrd.rrd_maximum,
		data_template_rrd.data_source_type_id
		FROM data_template_rrd
		WHERE data_template_rrd.local_data_id = ?
		ORDER BY local_data_template_rrd_id', array($local_data_id));
    /* ONLY make a new DS entry if:
    	- There is multiple data sources and this item is not the main one.
    	- There is only one data source (then use it) */
    if (sizeof($data_sources) > 0) {
        foreach ($data_sources as $data_source) {
            /* use the cacti ds name by default or the user defined one, if entered */
            $data_source_name = get_data_source_item_name($data_source['id']);
            if (empty($data_source['rrd_maximum'])) {
                /* in case no maximum is given, use "Undef" value */
                $data_source['rrd_maximum'] = 'U';
            } elseif (strpos($data_source['rrd_maximum'], '|query_') !== false) {
                $data_local = db_fetch_row_prepared('SELECT * FROM data_local WHERE id = ?', array($local_data_id));
                if ($data_source['rrd_maximum'] == '|query_ifSpeed|' || $data_source['rrd_maximum'] == '|query_ifHighSpeed|') {
                    $highSpeed = db_fetch_cell_prepared("SELECT field_value\n\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\tWHERE host_id = ?\n\t\t\t\t\tAND snmp_query_id = ?\n\t\t\t\t\tAND snmp_index = ?\n\t\t\t\t\tAND field_name = 'ifHighSpeed'", array($data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']));
                    if (!empty($highSpeed)) {
                        $data_source['rrd_maximum'] = $highSpeed * 1000000;
                    } else {
                        $data_source['rrd_maximum'] = substitute_snmp_query_data('|query_ifSpeed|', $data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']);
                    }
                } else {
                    $data_source['rrd_maximum'] = substitute_snmp_query_data($data_source['rrd_maximum'], $data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']);
                }
            } elseif ($data_source['rrd_maximum'] != 'U' && (int) $data_source['rrd_maximum'] <= (int) $data_source['rrd_minimum']) {
                /* max > min required, but take care of an "Undef" value */
                $data_source['rrd_maximum'] = (int) $data_source['rrd_minimum'] + 1;
            }
            /* min==max==0 won't work with rrdtool */
            if ($data_source['rrd_minimum'] == 0 && $data_source['rrd_maximum'] == 0) {
                $data_source['rrd_maximum'] = 'U';
            }
            $create_ds .= "DS:{$data_source_name}:" . $data_source_types[$data_source['data_source_type_id']] . ':' . $data_source['rrd_heartbeat'] . ':' . $data_source['rrd_minimum'] . ':' . $data_source['rrd_maximum'] . RRD_NL;
        }
    }
    $create_rra = '';
    /* loop through each available RRA for this DS */
    foreach ($rras as $rra) {
        $create_rra .= 'RRA:' . $consolidation_functions[$rra['consolidation_function_id']] . ':' . $rra['x_files_factor'] . ':' . $rra['steps'] . ':' . $rra['rows'] . RRD_NL;
    }
    /* check for structured path configuration, if in place verify directory
    	   exists and if not create it.
    	 */
    if (read_config_option('extended_paths') == 'on') {
        if (!is_dir(dirname($data_source_path))) {
            if (mkdir(dirname($data_source_path), 0775)) {
                if ($config['cacti_server_os'] != 'win32') {
                    $owner_id = fileowner($config['rra_path']);
                    $group_id = filegroup($config['rra_path']);
                    if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:boost.php


示例5: update_poller_cache

function update_poller_cache($local_data_id, $truncate_performed = false) {
	global $config;

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

	$data_input = db_fetch_row("select
		data_input.id,
		data_input.type_id,
		data_template_data.id as data_template_data_id,
		data_template_data.data_template_id,
		data_template_data.active,
		data_template_data.rrd_step
		from (data_template_data,data_input)
		where data_template_data.data_input_id=data_input.id
		and data_template_data.local_data_id=$local_data_id");

	$data_source = db_fetch_row("select host_id,snmp_query_id,snmp_index from data_local where id=$local_data_id");

	/* clear cache for this local_data_id */
	if (!$truncate_performed) {
		db_execute("delete from poller_item where local_data_id=$local_data_id");
	}

	/* we have to perform some additional sql queries if this is a "query" */
	if (($data_input["type_id"] == DATA_INPUT_TYPE_SNMP_QUERY) ||
		($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT_QUERY) ||
		($data_input["type_id"] == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER)){
		$field = data_query_field_list($data_input["data_template_data_id"]);

		if (($data_input["type_id"] != DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) &&
			(empty($field["output_type"]))) { return; }

		if (strlen($field["output_type"])) {
			$output_type_sql = "and snmp_query_graph_rrd.snmp_query_graph_id=" . $field["output_type"];
		}else{
			$output_type_sql = "";
		}

		$outputs = db_fetch_assoc("select
			snmp_query_graph_rrd.snmp_field_name,
			data_template_rrd.id as data_template_rrd_id
			from (snmp_query_graph_rrd,data_template_rrd)
			where snmp_query_graph_rrd.data_template_rrd_id=data_template_rrd.local_data_template_rrd_id
			$output_type_sql
			and snmp_query_graph_rrd.data_template_id=" . $data_input["data_template_id"] . "
			and data_template_rrd.local_data_id=$local_data_id");
	}

	if ($data_input["active"] == "on") {
		if (($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT) || ($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER)) { /* script */
			/* fall back to non-script server actions if the user is running a version of php older than 4.3 */
			if (($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) && (function_exists("proc_open"))) {
				$action = POLLER_ACTION_SCRIPT_PHP;
				$script_path = get_full_script_path($local_data_id);
			}else if (($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) && (!function_exists("proc_open"))) {
				$action = POLLER_ACTION_SCRIPT;
				$script_path = read_config_option("path_php_binary") . " -q " . get_full_script_path($local_data_id);
			}else{
				$action = POLLER_ACTION_SCRIPT;
				$script_path = get_full_script_path($local_data_id);
			}

			$num_output_fields = sizeof(db_fetch_assoc("select id from data_input_fields where data_input_id=" . $data_input["id"] . " and input_output='out' and update_rra='on'"));

			if ($num_output_fields == 1) {
				$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_id=$local_data_id");
				$data_source_item_name = get_data_source_item_name($data_template_rrd_id);
			}else{
				$data_source_item_name = "";
			}

			api_poller_cache_item_add($data_source["host_id"], array(), $local_data_id, $data_input["rrd_step"], $action, $data_source_item_name, 1, addslashes($script_path));
		}else if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP) { /* snmp */
			$host_fields = array_rekey(db_fetch_assoc("select
				data_input_fields.type_code,
				data_input_data.value
				from data_input_fields left join data_input_data
				on (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_input["data_template_data_id"] . ")
				where (data_input_fields.type_code='snmp_oid'
					or data_input_fields.type_code='hostname'
					or data_input_fields.type_code='snmp_community'
					or data_input_fields.type_code='snmp_username'
					or data_input_fields.type_code='snmp_password'
					or data_input_fields.type_code='snmp_auth_protocol'
					or data_input_fields.type_code='snmp_priv_passphrase'
					or data_input_fields.type_code='snmp_priv_protocol'
					or data_input_fields.type_code='snmp_context'
					or data_input_fields.type_code='snmp_version'
					or data_input_fields.type_code='snmp_port'
					or data_input_fields.type_code='snmp_timeout')
				and data_input_data.value != ''"), "type_code", "value");

			$data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_id=$local_data_id");

			api_poller_cache_item_add($data_source["host_id"], $host_fields, $local_data_id, $data_input["rrd_step"], 0, get_data_source_item_name($data_template_rrd_id), 1, (isset($host_fields["snmp_oid"]) ? $host_fields["snmp_oid"] : ""));
		}else if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP_QUERY) { /* snmp query */
			$snmp_queries = get_data_query_array($data_source["snmp_query_id"]);

			if (sizeof($outputs) > 0) {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:utility.php


示例6: update_poller_cache

function update_poller_cache($local_data_id, $commit = false)
{
    global $config;
    include_once $config["library_path"] . "/data_query.php";
    include_once $config["library_path"] . "/api_poller.php";
    $poller_items = array();
    $data_input = db_fetch_row("select\r\n\t\tdata_input.id,\r\n\t\tdata_input.type_id,\r\n\t\tdata_template_data.id as data_template_data_id,\r\n\t\tdata_template_data.data_template_id,\r\n\t\tdata_template_data.active,\r\n\t\tdata_template_data.rrd_step\r\n\t\tfrom (data_template_data,data_input)\r\n\t\twhere data_template_data.data_input_id=data_input.id\r\n\t\tand data_template_data.local_data_id={$local_data_id}");
    $data_source = db_fetch_row("select host_id,snmp_query_id,snmp_index from data_local where id={$local_data_id}");
    /* we have to perform some additional sql queries if this is a "query" */
    if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP_QUERY || $data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT_QUERY || $data_input["type_id"] == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER) {
        $field = data_query_field_list($data_input["data_template_data_id"]);
        if (strlen($field["output_type"])) {
            $output_type_sql = "and snmp_query_graph_rrd.snmp_query_graph_id='" . $field["output_type"] . "'";
        } else {
            $output_type_sql = "";
        }
        $outputs = db_fetch_assoc("select\r\n\t\t\tsnmp_query_graph_rrd.snmp_field_name,\r\n\t\t\tdata_template_rrd.id as data_template_rrd_id\r\n\t\t\tfrom (snmp_query_graph_rrd,data_template_rrd)\r\n\t\t\twhere snmp_query_graph_rrd.data_template_rrd_id=data_template_rrd.local_data_template_rrd_id\r\n\t\t\t{$output_type_sql}\r\n\t\t\tand snmp_query_graph_rrd.data_template_id=" . $data_input["data_template_id"] . "\r\n\t\t\tand data_template_rrd.local_data_id={$local_data_id}\r\n\t\t\torder by data_template_rrd.id");
    }
    if ($data_input["active"] == "on") {
        if ($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT || $data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER) {
            /* script */
            /* fall back to non-script server actions if the user is running a version of php older than 4.3 */
            if ($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER && function_exists("proc_open")) {
                $action = POLLER_ACTION_SCRIPT_PHP;
                $script_path = get_full_script_path($local_data_id);
            } else {
                if ($data_input["type_id"] == DATA_INPUT_TYPE_PHP_SCRIPT_SERVER && !function_exists("proc_open")) {
                    $action = POLLER_ACTION_SCRIPT;
                    $script_path = read_config_option("path_php_binary") . " -q " . get_full_script_path($local_data_id);
                } else {
                    $action = POLLER_ACTION_SCRIPT;
                    $script_path = get_full_script_path($local_data_id);
                }
            }
            $num_output_fields = sizeof(db_fetch_assoc("select id from data_input_fields where data_input_id=" . $data_input["id"] . " and input_output='out' and update_rra='on'"));
            if ($num_output_fields == 1) {
                $data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_id={$local_data_id}");
                $data_source_item_name = get_data_source_item_name($data_template_rrd_id);
            } else {
                $data_source_item_name = "";
            }
            $poller_items[] = api_poller_cache_item_add($data_source["host_id"], array(), $local_data_id, $data_input["rrd_step"], $action, $data_source_item_name, 1, addslashes($script_path));
        } else {
            if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP) {
                /* snmp */
                /* get the host override fields */
                $data_template_id = db_fetch_cell("SELECT data_template_id FROM data_template_data WHERE local_data_id={$local_data_id}");
                /* get host fields first */
                $host_fields = array_rekey(db_fetch_assoc("SELECT\r\n\t\t\t\tdata_input_fields.type_code,\r\n\t\t\t\tdata_input_data.value\r\n\t\t\t\tFROM data_input_fields\r\n\t\t\t\tLEFT JOIN data_input_data\r\n\t\t\t\tON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_input["data_template_data_id"] . ")\r\n\t\t\t\tWHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname') OR (type_code='host_id'))\r\n\t\t\t\tAND data_input_data.value != ''"), "type_code", "value");
                $data_template_fields = array_rekey(db_fetch_assoc("SELECT\r\n\t\t\t\tdata_input_fields.type_code,\r\n\t\t\t\tdata_input_data.value\r\n\t\t\t\tFROM data_input_fields\r\n\t\t\t\tLEFT JOIN data_input_data\r\n\t\t\t\tON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id={$data_template_id})\r\n\t\t\t\tWHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname'))\r\n\t\t\t\tAND data_template_data_id={$data_template_id}\r\n\t\t\t\tAND data_input_data.value != ''"), "type_code", "value");
                if (sizeof($host_fields)) {
                    if (sizeof($data_template_fields)) {
                        foreach ($data_template_fields as $key => $value) {
                            if (!isset($host_fields[$key])) {
                                $host_fields[$key] = $value;
                            }
                        }
                    }
                } elseif (sizeof($data_template_fields)) {
                    $host_fields = $data_template_fields;
                }
                $data_template_rrd_id = db_fetch_cell("select id from data_template_rrd where local_data_id={$local_data_id}");
                $poller_items[] = api_poller_cache_item_add($data_source["host_id"], $host_fields, $local_data_id, $data_input["rrd_step"], 0, get_data_source_item_name($data_template_rrd_id), 1, isset($host_fields["snmp_oid"]) ? $host_fields["snmp_oid"] : "");
            } else {
                if ($data_input["type_id"] == DATA_INPUT_TYPE_SNMP_QUERY) {
                    /* snmp query */
                    $snmp_queries = get_data_query_array($data_source["snmp_query_id"]);
                    /* get the host override fields */
                    $data_template_id = db_fetch_cell("SELECT data_template_id FROM data_template_data WHERE local_data_id={$local_data_id}");
                    /* get host fields first */
                    $host_fields = array_rekey(db_fetch_assoc("SELECT\r\n\t\t\t\tdata_input_fields.type_code,\r\n\t\t\t\tdata_input_data.value\r\n\t\t\t\tFROM data_input_fields\r\n\t\t\t\tLEFT JOIN data_input_data\r\n\t\t\t\tON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=" . $data_input["data_template_data_id"] . ")\r\n\t\t\t\tWHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname'))\r\n\t\t\t\tAND data_input_data.value != ''"), "type_code", "value");
                    $data_template_fields = array_rekey(db_fetch_assoc("SELECT\r\n\t\t\t\tdata_input_fields.type_code,\r\n\t\t\t\tdata_input_data.value\r\n\t\t\t\tFROM data_input_fields\r\n\t\t\t\tLEFT JOIN data_input_data\r\n\t\t\t\tON (data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id={$data_template_id})\r\n\t\t\t\tWHERE ((type_code LIKE 'snmp_%') OR (type_code='hostname'))\r\n\t\t\t\tAND data_template_data_id={$data_template_id}\r\n\t\t\t\tAND data_input_data.value != ''"), "type_code", "value");
                    if (sizeof($host_fields)) {
                        if (sizeof($data_template_fields)) {
                            foreach ($data_template_fields as $key => $value) {
                                if (!isset($host_fields[$key])) {
                                    $host_fields[$key] = $value;
                                }
                            }
                        }
                    } elseif (sizeof($data_template_fields)) {
                        $host_fields = $data_template_fields;
                    }
                    if (sizeof($outputs) > 0) {
                        foreach ($outputs as $output) {
                            if (isset($snmp_queries["fields"][$output["snmp_field_name"]]["oid"])) {
                                $oid = $snmp_queries["fields"][$output["snmp_field_name"]]["oid"] . "." . $data_source["snmp_index"];
                                if (isset($snmp_queries["fields"][$output["snmp_field_name"]]["oid_suffix"])) {
                                    $oid .= "." . $snmp_queries["fields"][$output["snmp_field_name"]]["oid_suffix"];
                                }
                            }
                            if (!empty($oid)) {
                                $poller_items[] = api_poller_cache_item_add($data_source["host_id"], $host_fields, $local_data_id, $data_input["rrd_step"], 0, get_data_source_item_name($output["data_template_rrd_id"]), sizeof($outputs), $oid);
                            }
                        }
                    }
                } else {
                    if ($data_input["type_id"] == DATA_INPUT_TYPE_SCRIPT_QUERY || $data_input["type_id"] == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER) {
                        /* script query */
                        $script_queries = get_data_query_array($data_source["snmp_query_id"]);
//.........这里部分代码省略.........
开发者ID:resmon,项目名称:resmon-cacti,代码行数:101,代码来源:utility.php


示例7: rrdtool_function_tune

function rrdtool_function_tune($rrd_tune_array) {
	require(CACTI_BASE_PATH . "/include/global_arrays.php");
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php");

	$data_source_name = get_data_source_item_name($rrd_tune_array["data_source_id"]);
	$data_source_type = $data_source_types{$rrd_tune_array["data-source-type"]};
	$data_source_path = api_data_source_path_get($rrd_tune_array["data_source_id"], true);

	if ($rrd_tune_array["heartbeat"] != "") {
		$rrd_tune .= " --heartbeat $data_source_name:" . $rrd_tune_array["heartbeat"];
	}

	if ($rrd_tune_array["minimum"] != "") {
		$rrd_tune .= " --minimum $data_source_name:" . $rrd_tune_array["minimum"];
	}

	if ($rrd_tune_array["maximum"] != "") {
		$rrd_tune .= " --maximum $data_source_name:" . $rrd_tune_array["maximum"];
	}

	if ($rrd_tune_array["data-source-type"] != "") {
		$rrd_tune .= " --data-source-type $data_source_name:" . $data_source_type;
	}

	if ($rrd_tune_array["data-source-rename"] != "") {
		$rrd_tune .= " --data-source-rename $data_source_name:" . $rrd_tune_array["data-source-rename"];
	}

	if ($rrd_tune != "") {
		if (file_exists($data_source_path) == true) {
			$fp = popen(read_config_option("path_rrdtool") . " tune $data_source_path $rrd_tune", "r");
			pclose($fp);

			log_save("RRD_TUNE: " . addslashes(read_config_option("path_rrdtool")) . " tune $data_source_path $rrd_tune", SEV_DEBUG, FACIL_POLLER);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:37,代码来源:rrd.php


示例8: rrd_repair

function rrd_repair($data_source_id) {
	global $config, $rrd_tune_array;
	require(CACTI_BASE_PATH . "/include/data_source/data_source_arrays.php");

	$data_source_name = get_data_source_item_name($rrd_tune_array["data_source_id"]);
	$data_source_type = $data_source_types{$rrd_tune_array["data-source-type"]};
	$data_source_path = get_data_source_path($rrd_tune_array["data_source_id"], true);


}
开发者ID:songchin,项目名称:Cacti,代码行数:10,代码来源:rrd.php



注:本文中的get_data_source_item_name函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_data_source_path函数代码示例发布时间:2022-05-15
下一篇:
PHP get_data_row函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap