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

PHP get_data_source_path函数代码示例

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

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



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

示例1: rrdtool_function_graph


//.........这里部分代码省略.........
			$graph_date = "Y" . $datechar . "M" . $datechar . "d H:i:s";
			break;
	}

	/* display the timespan for zoomed graphs */
	if ((isset($graph_data_array["graph_start"])) && (isset($graph_data_array["graph_end"]))) {
		if (($graph_data_array["graph_start"] < 0) && ($graph_data_array["graph_end"] < 0)) {
			$graph_legend .= "COMMENT:\"From " . date($graph_date, time()+$graph_data_array["graph_start"]) . " To " . date($graph_date, time()+$graph_data_array["graph_end"]) . "\\c\"" . RRD_NL . "COMMENT:\"\\n\"" . RRD_NL;
		}else if (($graph_data_array["graph_start"] >= 0) && ($graph_data_array["graph_end"] >= 0)) {
			$graph_legend .= "COMMENT:\"From " . date($graph_date, $graph_data_array["graph_start"]) . " To " . date($graph_date, $graph_data_array["graph_end"]) . "\\c\"" . RRD_NL . "COMMENT:\"\\n\"" . RRD_NL;
		}
	}

	/* basic graph options */
	$graph_opts .=
		"--imgformat=" . $image_types{$graph["image_format_id"]} . RRD_NL .
		"--start=$graph_start" . RRD_NL .
		"--end=$graph_end" . RRD_NL .
		"--title=\"" . $graph["title_cache"] . "\"" . RRD_NL .
		"$rigid" .
		"--base=" . $graph["base_value"] . RRD_NL .
		"--height=$graph_height" . RRD_NL .
		"--width=$graph_width" . RRD_NL .
		"$scale" .
		"$unit_exponent_value" .
		"$graph_legend" .
		"--vertical-label=\"" . $graph["vertical_label"] . "\"" . RRD_NL;

	$i = 0;
	if (sizeof($graph_items > 0)) {
	foreach ($graph_items as $graph_item) {
		if ((ereg("(AREA|STACK|LINE[123])", $graph_item_types{$graph_item["graph_type_id"]})) && ($graph_item["data_source_name"] != "")) {
			/* use a user-specified ds path if one is entered */
			$data_source_path = get_data_source_path($graph_item["local_data_id"], true);

			/* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
			$data_source_path = str_replace(":", "\:", $data_source_path);

			if (!empty($data_source_path)) {
				/* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
				to a function that matches the digits with letters. rrdtool likes letters instead
				of numbers in DEF names; especially with CDEF's. cdef's are created
				the same way, except a 'cdef' is put on the beginning of the hash */
				$graph_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=\"$data_source_path\":" . $graph_item["data_source_name"] . ":" . $consolidation_functions{$graph_item["consolidation_function_id"]} . RRD_NL;

				//print "ds: " . $graph_item["data_template_rrd_id"] . "<br>";
				$cf_ds_cache{$graph_item["data_template_rrd_id"]}{$graph_item["consolidation_function_id"]} = "$i";

				$i++;
			}
		}

		/* +++++++++++++++++++++++ LEGEND: TEXT SUBSITUTION (<>'s) +++++++++++++++++++++++ */

		/* note the current item_id for easy access */
		$graph_item_id = $graph_item["graph_templates_item_id"];

		/* the following fields will be searched for graph variables */
		$variable_fields = array(
			"text_format" => array(
				"process_no_legend" => false
				),
			"value" => array(
				"process_no_legend" => true
				)
			);
开发者ID:songchin,项目名称:Cacti,代码行数:67,代码来源:rrd.php


示例2: api_poller_cache_item_add

function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "")
{
    $host = db_fetch_row("select\n\t\thost.id,\n\t\thost.hostname,\n\t\thost.snmp_community,\n\t\thost.snmp_version,\n\t\thost.snmp_username,\n\t\thost.snmp_password,\n\t\thost.snmp_port,\n\t\thost.snmp_timeout,\n\t\thost.disabled\n\t\tfrom host\n\t\twhere host.id={$host_id}");
    /* the $host_field_override array can be used to override certain host fields in the poller cache */
    if (isset($host)) {
        $host = array_merge($host, $host_field_override);
    }
    if (isset($host["id"]) || isset($host_id)) {
        if (isset($host)) {
            if ($host["disabled"] == "on") {
                return true;
            }
        } else {
            if ($poller_action_id == 0) {
                return true;
            }
            $host["id"] = 0;
            $host["snmp_community"] = "";
            $host["snmp_timeout"] = "";
            $host["snmp_username"] = "";
            $host["snmp_password"] = "";
            $host["snmp_version"] = "";
            $host["snmp_port"] = "";
            $host["hostname"] = "None";
        }
        if ($poller_action_id == 0) {
            if ($host["snmp_version"] < 1 || $host["snmp_version"] > 3 || $host["snmp_community"] == "" && $host["snmp_version"] != 3) {
                return true;
            }
        }
        return db_execute("insert into poller_item (local_data_id,host_id,action,hostname,\n\t\t\tsnmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,\n\t\t\trrd_num,arg1,arg2,arg3) values ({$local_data_id}," . $host["id"] . ",{$poller_action_id},'" . $host["hostname"] . "',\n\t\t\t'" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "',\n\t\t\t'" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "',\n\t\t\t'{$data_source_item_name}','" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',\n\t\t\t'{$num_rrd_items}','{$arg1}','{$arg2}','{$arg3}')");
    }
}
开发者ID:songchin,项目名称:Cacti,代码行数:33,代码来源:api_poller.php


示例3: api_poller_cache_item_add

function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = '', $arg2 = '', $arg3 = '')
{
    static $hosts = array();
    if (!isset($hosts[$host_id])) {
        $host = db_fetch_row_prepared('SELECT
		host.id,
		host.hostname,
		host.snmp_community,
		host.snmp_version,
		host.snmp_username,
		host.snmp_password,
		host.snmp_auth_protocol,
		host.snmp_priv_passphrase,
		host.snmp_priv_protocol,
		host.snmp_context,
		host.snmp_port,
		host.snmp_timeout,
		host.disabled
		FROM host
		WHERE host.id = ?', array($host_id));
        $hosts[$host_id] = $host;
    } else {
        $host = $hosts[$host_id];
    }
    /* the $host_field_override array can be used to override certain host fields in the poller cache */
    if (isset($host)) {
        $host = array_merge($host, $host_field_override);
    }
    if (isset($host['id']) || isset($host_id)) {
        if (isset($host)) {
            if ($host['disabled'] == 'on') {
                return;
            }
        } else {
            if ($poller_action_id == 0) {
                return;
            }
            $host['id'] = 0;
            $host['snmp_community'] = '';
            $host['snmp_timeout'] = '';
            $host['snmp_username'] = '';
            $host['snmp_password'] = '';
            $host['snmp_auth_protocol'] = '';
            $host['snmp_priv_passphrase'] = '';
            $host['snmp_priv_protocol'] = '';
            $host['snmp_context'] = '';
            $host['snmp_version'] = '';
            $host['snmp_port'] = '';
            $host['hostname'] = 'None';
        }
        if ($poller_action_id == 0) {
            if ($host['snmp_version'] < 1 || $host['snmp_version'] > 3 || $host['snmp_community'] == '' && $host['snmp_version'] != 3) {
                return;
            }
        }
        $rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);
        return "({$local_data_id}, " . '0, ' . $host['id'] . ", {$poller_action_id}," . db_qstr($host['hostname']) . ",\n\t\t\t" . db_qstr($host['snmp_community']) . ', ' . db_qstr($host['snmp_version']) . ', ' . db_qstr($host['snmp_timeout']) . ",\n\t\t\t" . db_qstr($host['snmp_username']) . ', ' . db_qstr($host['snmp_password']) . ', ' . db_qstr($host['snmp_auth_protocol']) . ",\n\t\t\t" . db_qstr($host['snmp_priv_passphrase']) . ', ' . db_qstr($host['snmp_priv_protocol']) . ', ' . db_qstr($host['snmp_context']) . ",\n\t\t\t" . db_qstr($host['snmp_port']) . ', ' . db_qstr($data_source_item_name) . ', ' . db_qstr(clean_up_path(get_data_source_path($local_data_id, true))) . ",\n\t\t\t" . db_qstr($num_rrd_items) . ', ' . db_qstr($rrd_step) . ', ' . db_qstr($rrd_next_step) . ', ' . db_qstr($arg1) . ', ' . db_qstr($arg2) . ', ' . db_qstr($arg3) . ", '1')";
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:59,代码来源:api_poller.php


示例4: api_poller_cache_item_add

function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "")
{
    global $cnn_id;
    static $hosts = array();
    if (!isset($hosts[$host_id])) {
        $host = db_fetch_row("select\n\t\thost.id,\n\t\thost.hostname,\n\t\thost.snmp_community,\n\t\thost.snmp_version,\n\t\thost.snmp_username,\n\t\thost.snmp_password,\n\t\thost.snmp_auth_protocol,\n\t\thost.snmp_priv_passphrase,\n\t\thost.snmp_priv_protocol,\n\t\thost.snmp_context,\n\t\thost.snmp_port,\n\t\thost.snmp_timeout,\n\t\thost.disabled\n\t\tfrom host\n\t\twhere host.id={$host_id}");
        $hosts[$host_id] = $host;
    } else {
        $host = $hosts[$host_id];
    }
    /* the $host_field_override array can be used to override certain host fields in the poller cache */
    if (isset($host)) {
        $host = array_merge($host, $host_field_override);
    }
    if (isset($host["id"]) || isset($host_id)) {
        if (isset($host)) {
            if ($host["disabled"] == "on") {
                return;
            }
        } else {
            if ($poller_action_id == 0) {
                return;
            }
            $host["id"] = 0;
            $host["snmp_community"] = "";
            $host["snmp_timeout"] = "";
            $host["snmp_username"] = "";
            $host["snmp_password"] = "";
            $host["snmp_auth_protocol"] = "";
            $host["snmp_priv_passphrase"] = "";
            $host["snmp_priv_protocol"] = "";
            $host["snmp_context"] = "";
            $host["snmp_version"] = "";
            $host["snmp_port"] = "";
            $host["hostname"] = "None";
        }
        if ($poller_action_id == 0) {
            if ($host["snmp_version"] < 1 || $host["snmp_version"] > 3 || $host["snmp_community"] == "" && $host["snmp_version"] != 3) {
                return;
            }
        }
        $rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);
        return "({$local_data_id}, " . "0, " . $host["id"] . ", {$poller_action_id}," . $cnn_id->qstr($host["hostname"]) . ",\n\t\t\t" . $cnn_id->qstr($host["snmp_community"]) . ", " . $cnn_id->qstr($host["snmp_version"]) . ", " . $cnn_id->qstr($host["snmp_timeout"]) . ",\n\t\t\t" . $cnn_id->qstr($host["snmp_username"]) . ", " . $cnn_id->qstr($host["snmp_password"]) . ", " . $cnn_id->qstr($host["snmp_auth_protocol"]) . ",\n\t\t\t" . $cnn_id->qstr($host["snmp_priv_passphrase"]) . ", " . $cnn_id->qstr($host["snmp_priv_protocol"]) . ", " . $cnn_id->qstr($host["snmp_context"]) . ",\n\t\t\t" . $cnn_id->qstr($host["snmp_port"]) . ", " . $cnn_id->qstr($data_source_item_name) . ", " . $cnn_id->qstr(clean_up_path(get_data_source_path($local_data_id, true))) . ",\n\t\t\t" . $cnn_id->qstr($num_rrd_items) . ", " . $cnn_id->qstr($rrd_step) . ", " . $cnn_id->qstr($rrd_next_step) . ", " . $cnn_id->qstr($arg1) . ", " . $cnn_id->qstr($arg2) . ", " . $cnn_id->qstr($arg3) . ", '1')";
    }
}
开发者ID:teddywen,项目名称:cacti,代码行数:45,代码来源:api_poller.php


示例5: api_poller_cache_item_add

function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "") {
	$host = db_fetch_row("select
		host.id,
		host.hostname,
		host.snmp_community,
		host.snmp_version,
		host.snmp_username,
		host.snmp_password,
		host.snmp_port,
		host.snmp_timeout,
		host.disabled
		from host
		where host.id=$host_id");

	/* the $host_field_override array can be used to override certain host fields in the poller cache */
	if (isset($host)) {
		$host = array_merge($host, $host_field_override);
	}

	if (isset($host["id"]) || (isset($host_id))) {
		if (isset($host)) {
			if ($host["disabled"] == "on") {
				return true;
			}
		} else {
			$host["id"] = 0;
			$host["snmp_community"] = "";
			$host["snmp_timeout"] = "";
			$host["snmp_username"] = "";
			$host["snmp_password"] = "";
			$host["snmp_version"] = "";
			$host["snmp_port"] = "";
			$host["hostname"] = "None";
		}

		return db_execute("insert into poller_item (local_data_id,host_id,action,hostname,
			snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,
			rrd_num,arg1,arg2,arg3) values ($local_data_id," . $host["id"] . ",$poller_action_id,'" . $host["hostname"] . "',
			'" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "',
			'" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "',
			'$data_source_item_name','" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',
			'$num_rrd_items','$arg1','$arg2','$arg3')");
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:44,代码来源:api_poller.php


示例6: errorimage_check_graphs

function errorimage_check_graphs()
{
    global $config;
    $local_graph_id = $_GET['local_graph_id'];
    $graph_items = db_fetch_assoc("select\r\n\t\tdata_template_rrd.local_data_id\r\n\t\tfrom graph_templates_item\r\n\t\tleft join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)\r\n\t\twhere graph_templates_item.local_graph_id={$local_graph_id}\r\n\t\torder by graph_templates_item.sequence");
    $ids = array();
    foreach ($graph_items as $graph) {
        if ($graph['local_data_id'] != '') {
            $ids[] = $graph['local_data_id'];
        }
    }
    $ids = array_unique($ids);
    if (!empty($_GET["graph_nolegend"])) {
        $height = read_graph_config_option("default_height") + 62;
        $width = read_graph_config_option("default_width") + 95;
    } else {
        $hw = db_fetch_row("SELECT width, height \r\n\t\t\tFROM graph_templates_graph \r\n\t\t\tWHERE local_graph_id=" . $_GET['local_graph_id']);
        $hr = db_fetch_cell("SELECT count(*) FROM graph_templates_item WHERE local_graph_id=" . $_GET['local_graph_id'] . " AND hard_return='on'");
        $height = $hw['height'] + 16 * $hr + 90;
        // # hard rules, plus room for date
        $width = $hw['width'] + 95;
    }
    foreach ($ids as $id => $local_data_id) {
        $data_source_path = get_data_source_path($local_data_id, true);
        if (!file_exists($data_source_path)) {
            $filename = $config['base_path'] . '/plugins/errorimage/images/no-datasource.png';
            if (function_exists("imagecreatefrompng")) {
                echo errorimage_resize_png($filename, $width, $height);
            } else {
                $file = fopen($filename, 'rb');
                echo fread($file, filesize($filename));
                fclose($file);
            }
            exit;
        }
    }
}
开发者ID:resmon,项目名称:resmon-cacti,代码行数:37,代码来源:setup.php


示例7: api_poller_cache_item_add

function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "") {
	$host = db_fetch_row("select
		host.id,
		host.hostname,
		host.snmp_community,
		host.snmp_version,
		host.snmp_username,
		host.snmp_password,
		host.snmp_auth_protocol,
		host.snmp_priv_passphrase,
		host.snmp_priv_protocol,
		host.snmp_context,
		host.snmp_port,
		host.snmp_timeout,
		host.disabled
		from host
		where host.id=$host_id");

	/* the $host_field_override array can be used to override certain host fields in the poller cache */
	if (isset($host)) {
		$host = array_merge($host, $host_field_override);
	}

	if (isset($host["id"]) || (isset($host_id))) {
		if (isset($host)) {
			if ($host["disabled"] == "on") {
				return true;
			}
		} else {
			if ($poller_action_id == 0) {
				return true;
			}

			$host["id"] = 0;
			$host["snmp_community"] = "";
			$host["snmp_timeout"] = 0;
			$host["snmp_username"] = "";
			$host["snmp_password"] = "";
			$host["snmp_auth_protocol"] = "";
			$host["snmp_priv_passphrase"] = "";
			$host["snmp_priv_protocol"] = "";
			$host["snmp_context"] = "";
			$host["snmp_version"] = 0;
			$host["snmp_port"] = 161;
			$host["hostname"] = "None";
		}

		if ($poller_action_id == 0) {
			if (($host["snmp_version"] < 1) || ($host["snmp_version"] > 3) ||
				($host["snmp_community"] == "" && $host["snmp_version"] != 3)) {
				return true;
			}
		}

		$rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);

		return db_execute("INSERT INTO poller_item (local_data_id, host_id, action,hostname,
			snmp_community, snmp_version, snmp_timeout, snmp_username, snmp_password,
			snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_context, snmp_port, rrd_name, rrd_path,
			rrd_num, rrd_step, rrd_next_step, arg1, arg2, arg3)
			VALUES
			($local_data_id, " . $host["id"] . ", $poller_action_id,'" . $host["hostname"] . "',
			'" . $host["snmp_community"]       . "', '" . $host["snmp_version"]       . "', '" . $host["snmp_timeout"] . "',
			'" . $host["snmp_username"]        . "', '" . $host["snmp_password"]      . "', '" . $host["snmp_auth_protocol"] . "',
			'" . $host["snmp_priv_passphrase"] . "', '" . $host["snmp_priv_protocol"] . "', '" . $host["snmp_context"] . "',
			'" . $host["snmp_port"]            . "', '$data_source_item_name', '"     . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',
			'$num_rrd_items', '$rrd_step', '$rrd_next_step', '$arg1', '$arg2', '$arg3')");
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:69,代码来源:api_poller.php


示例8: process_poller_output_rt

function process_poller_output_rt($rrdtool_pipe, $poller_id, $interval) {
	global $config;

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

	/* let's count the number of rrd files we processed */
	$rrds_processed = 0;

	/* create/update the rrd files */
	$results = db_fetch_assoc("SELECT
		poller_output_rt.output,
		poller_output_rt.time,
		poller_output_rt.local_data_id,
		poller_item.rrd_path,
		poller_item.rrd_name,
		poller_item.rrd_num
		FROM (poller_output_rt,poller_item)
		WHERE (poller_output_rt.local_data_id=poller_item.local_data_id
		AND poller_output_rt.rrd_name=poller_item.rrd_name)
		AND poller_output_rt.poller_id = $poller_id");

	if (sizeof($results) > 0) {
		/* create an array keyed off of each .rrd file */
		foreach ($results as $item) {
			$rt_graph_path    = read_config_option("realtime_cache_path") . "/realtime_" . $item["local_data_id"] . "_5.rrd";
			$data_source_path = get_data_source_path($item['local_data_id'], true);

			/* create rt rrd */
			if (!file_exists($rt_graph_path)) {
				/* get the syntax */
				$command = @rrdtool_function_create($item['local_data_id'], true);

				/* change permissions so that the poller can clear */
				@chmod($rt_graph_path, 0666);

				/* replace path */
				$command = str_replace($data_source_path, $rt_graph_path, $command);

				/* replace step */
				$command = preg_replace('/--step\s(\d+)/', '--step ' . $interval, $command);

				/* WIN32: before sending this command off to rrdtool, get rid
				of all of the '\' characters. Unix does not care; win32 does.
				Also make sure to replace all of the fancy \'s at the end of the line,
				but make sure not to get rid of the "\n"'s that are supposed to be
				in there (text format) */
				$command = str_replace("\\\n", " ", $command);

				/* create the rrdfile */
				shell_exec($command);
			}else{
				/* change permissions so that the poller can clear */
				@chmod($rt_graph_path, 0666);
			}

			/* now, let's update the path to keep the RRD's updated */
			$item["rrd_path"] = $rt_graph_path;

			/* cleanup the value */
			$value            = trim($item["output"]);
			$unix_time        = strtotime($item["time"]);

			$rrd_update_array{$item["rrd_path"]}["local_data_id"] = $item["local_data_id"];

			/* single one value output */
			if ((is_numeric($value)) || ($value == "U")) {
				$rrd_update_array{$item["rrd_path"]}["times"][$unix_time]{$item["rrd_name"]} = $value;
			/* multiple value output */
			}else{
				$values = explode(" ", $value);

				$rrd_field_names = array_rekey(db_fetch_assoc("SELECT
					data_template_rrd.data_source_name,
					data_input_fields.data_name
					FROM (data_template_rrd,data_input_fields)
					WHERE data_template_rrd.data_input_field_id=data_input_fields.id
					AND data_template_rrd.local_data_id=" . $item["local_data_id"]), "data_name", "data_source_name");

				for ($i=0; $i<count($values); $i++) {
					if (preg_match("/^([a-zA-Z0-9_\.-]+):([eE0-9\+\.-]+)$/", $values[$i], $matches)) {
						if (isset($rrd_field_names{$matches[1]})) {
							$rrd_update_array{$item["rrd_path"]}["times"][$unix_time]{$rrd_field_names{$matches[1]}} = $matches[2];
						}
					}
				}
			}

			/* fallback values */
			if ((!isset($rrd_update_array{$item["rrd_path"]}["times"][$unix_time])) && ($item["rrd_name"] != "")) {
				$rrd_update_array{$item["rrd_path"]}["times"][$unix_time]{$item["rrd_name"]} = "U";
			}else if ((!isset($rrd_update_array{$item["rrd_path"]}["times"][$unix_time])) && ($item["rrd_name"] == "")) {
				unset($rrd_update_array{$item["rrd_path"]});
			}
		}

		/* make sure each .rrd file has complete data */
		reset($results);
		foreach ($results as $item) {
			db_execute("DELETE FROM poller_output_rt
				WHERE local_data_id='" . $item["local_data_id"] . "'
//.........这里部分代码省略.........
开发者ID:avillaverdec,项目名称:cacti,代码行数:101,代码来源:poller_rt.php


示例9: rrdtool_function_graph


//.........这里部分代码省略.........
                /* remember the last CF for this data source for use with GPRINT
                 * if e.g. an AREA/AVERAGE and a LINE/MAX is used
                 * we will have AVERAGE first and then MAX, depending on GPRINT sequence */
                $last_graph_cf["data_source_name"]["local_data_template_rrd_id"] = $graph_cf;
                /* remember this for second foreach loop */
                $graph_items[$key]["cf_reference"] = $graph_cf;
            } elseif ($graph_item["graph_type_id"] == GRAPH_ITEM_TYPE_GPRINT) {
                /* ATTENTION!
                 * the "CF" given on graph_item edit screen for GPRINT is indeed NOT a real "CF",
                 * but an aggregation function
                 * see "man rrdgraph_data" for the correct VDEF based notation
                 * so our task now is to "guess" the very graph_item, this GPRINT is related to
                 * and to use that graph_item's CF */
                if (isset($last_graph_cf["data_source_name"]["local_data_template_rrd_id"])) {
                    $graph_cf = $last_graph_cf["data_source_name"]["local_data_template_rrd_id"];
                    /* remember this for second foreach loop */
                    $graph_items[$key]["cf_reference"] = $graph_cf;
                } else {
                    $graph_cf = generate_graph_best_cf($graph_item["local_data_id"], $graph_item["consolidation_function_id"]);
                    /* remember this for second foreach loop */
                    $graph_items[$key]["cf_reference"] = $graph_cf;
                }
            } else {
                /* all other types are based on the best matching CF */
                $graph_cf = generate_graph_best_cf($graph_item["local_data_id"], $graph_item["consolidation_function_id"]);
                /* remember this for second foreach loop */
                $graph_items[$key]["cf_reference"] = $graph_cf;
            }
            if (!empty($graph_item["local_data_id"]) && !isset($cf_ds_cache[$graph_item["data_template_rrd_id"]][$graph_cf])) {
                /* use a user-specified ds path if one is entered */
                if (isset($graph_data_array['export_realtime'])) {
                    $data_source_path = read_config_option("realtime_cache_path") . "/user_" . session_id() . "_" . $graph_item["local_data_id"] . ".rrd";
                } else {
                    $data_source_path = get_data_source_path($graph_item["local_data_id"], true);
                }
                /* FOR WIN32: Escape all colon for drive letters (ex. D\:/path/to/rra) */
                $data_source_path = str_replace(":", "\\:", $data_source_path);
                if (!empty($data_source_path)) {
                    /* NOTE: (Update) Data source DEF names are created using the graph_item_id; then passed
                    			to a function that matches the digits with letters. rrdtool likes letters instead
                    			of numbers in DEF names; especially with CDEF's. cdef's are created
                    			the same way, except a 'cdef' is put on the beginning of the hash */
                    $graph_defs .= "DEF:" . generate_graph_def_name(strval($i)) . "=" . cacti_escapeshellarg($data_source_path) . ":" . cacti_escapeshellarg($graph_item["data_source_name"], true) . ":" . $consolidation_functions[$graph_cf] . RRD_NL;
                    $cf_ds_cache[$graph_item["data_template_rrd_id"]][$graph_cf] = "{$i}";
                    $i++;
                }
            }
            /* cache cdef value here to support data query variables in the cdef string */
            if (empty($graph_item["cdef_id"])) {
                $graph_item["cdef_cache"] = "";
                $graph_items[$j]["cdef_cache"] = "";
            } else {
                $graph_item["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
                $graph_items[$j]["cdef_cache"] = get_cdef($graph_item["cdef_id"]);
            }
            /* +++++++++++++++++++++++ LEGEND: TEXT SUBSTITUTION (<>'s) +++++++++++++++++++++++ */
            /* note the current item_id for easy access */
            $graph_item_id = $graph_item["graph_templates_item_id"];
            /* the following fields will be searched for graph variables */
            $variable_fields = array("text_format" => array("process_no_legend" => false), "value" => array("process_no_legend" => true), "cdef_cache" => array("process_no_legend" => true));
            /* loop through each field that we want to substitute values for:
            			currently: text format and value */
            while (list($field_name, $field_array) = each($variable_fields)) {
                /* certain fields do not require values when the legend is not to be shown */
                if ($field_array["process_no_legend"] == false && isset($graph_data_array["graph_nolegend"])) {
                    continue;
开发者ID:MrWnn,项目名称:cacti,代码行数:67,代码来源:rrd.php


示例10: get_rrd_cfs

function get_rrd_cfs($local_data_id)
{
    global $rrd_cfs, $consolidation_functions;
    $rrdfile = get_data_source_path($local_data_id, TRUE);
    if (!isset($rrd_cfs)) {
        $rrd_cfs = array();
    } else {
        if (array_key_exists($local_data_id, $rrd_cfs)) {
            return $rrd_cfs[$local_data_id];
        }
    }
    $cfs = array();
    $output = rrdtool_execute("info {$rrdfile}", FALSE, RRDTOOL_OUTPUT_STDOUT);
    /* search for
     * 		rra[0].cf = "LAST"
     * or similar
     */
    if (strlen($output)) {
        $output = explode("\n", $output);
        if (sizeof($output)) {
            foreach ($output as $line) {
                if (substr_count($line, ".cf")) {
                    $values = explode("=", $line);
                    if (!in_array(trim($values[1], '" '), $cfs)) {
                        $cfs[] = trim($values[1], '" ');
                    }
                }
            }
        }
    }
    $new_cfs = array();
    if (sizeof($cfs)) {
        foreach ($cfs as $cf) {
            switch ($cf) {
                case "AVG":
                case "AVERAGE":
                    $new_cfs[] = array_search('AVERAGE', $consolidation_functions);
                    break;
                case "MIN":
                    $new_cfs[] = array_search('MIN', $consolidation_functions);
                    break;
                case "MAX":
                    $new_cfs[] = array_search('MAX', $consolidation_functions);
                    break;
                case "LAST":
                    $new_cfs[] = array_search('LAST', $consolidation_functions);
                    break;
            }
        }
    }
    $rrd_cfs[$local_data_id] = $new_cfs;
    return $new_cfs;
}
开发者ID:songchin,项目名称:Cacti,代码行数:53,代码来源:functions.php


示例11: thold_rrd_last

function thold_rrd_last($local_data_id)
{
    $last_time_entry = @rrdtool_execute('last ' . trim(get_data_source_path($local_data_id, true)), false, RRDTOOL_OUTPUT_STDOUT);
    return trim($last_time_entry);
}
开发者ID:Cacti,项目名称:plugin_thold,代码行数:5,代码来源:thold_functions.php


示例12: get_rrd_cfs

function get_rrd_cfs($local_data_id) {
	global $rrd_cfs;
	require(CACTI_BASE_PATH . "/include/presets/preset_rra_arrays.php");

	$rrdfile = get_data_source_path($local_data_id, TRUE);

	if (!isset($rrd_cfs)) {
		$rrd_cfs = array();
	}else if (array_key_exists($local_data_id, $rrd_cfs)) {
		return $rrd_cfs[$local_data_id];
	}

	$cfs = array();

	$output = rrdtool_execute("info $rrdfile", FALSE, RRDTOOL_OUTPUT_STDOUT);

	/* search for
	 * 		rra[0].cf = "LAST"
	 * or similar
	 */
	if (strlen($output)) {
		$output = explode("\n", $output);

		if (sizeof($output)) {
			foreach($output as $line) {
				if (substr_count($line, ".cf")) {
					$values = explode("=",$line);

					if (!in_array(trim($values[1]), $cfs)) {
						$cfs[] = trim($values[1], '" ');
					}
				}
			}
		}
	}

	$new_cfs = array();

	if (sizeof($cfs)) {
		foreach($cfs as $cf) {
			$new_cfs[] = array_search($cf, $consolidation_functions);
		}
	}

	$rrd_cfs[$local_data_id] = $new_cfs;

	return $new_cfs;
}
开发者ID:songchin,项目名称:Cacti,代码行数:48,代码来源:functions.php


示例13: api_poller_cache_item_add

/** api_poller_cache_item_add - add an item to the poller cache
 *
 * @param int $device_id
 * @param string $device_field_override
 * @param int $local_data_id
 * @param int $rrd_step
 * @param int $poller_action_id
 * @param string $data_source_item_name
 * @param int $num_rrd_items
 * @param string $arg1
 * @param string $arg2
 * @param string $arg3
 * @return unknown_type
 */
function api_poller_cache_item_add($device_id, $device_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "") {
	static $devices = array();

	if (!isset($devices[$device_id])) {
		$device = db_fetch_row("select
			device.id,
			device.poller_id,
			device.hostname,
			device.snmp_community,
			device.snmp_version,
			device.snmp_username,
			device.snmp_password,
			device.snmp_auth_protocol,
			device.snmp_priv_passphrase,
			device.snmp_priv_protocol,
			device.snmp_context,
			device.snmp_port,
			device.snmp_timeout,
			device.disabled
			from device
			where device.id=$device_id");

		$devices[$device_id] = $device;
	} else {
		$device = $devices[$device_id];
	}

	/* the $device_field_override array can be used to override certain device fields in the poller cache */
	if (isset($device)) {
		$device = array_merge($device, $device_field_override);
	}

	if (isset($device["id"]) || (isset($device_id))) {
		if (isset($device)) {
			if ($device["disabled"] == CHECKED) {
				return;
			}
		} else {
			if ($poller_action_id == 0) {
				return;
			}

			$device["id"] = 0;
			$device["poller_id"] = 0;
			$device["snmp_community"] = "";
			$device["snmp_timeout"] = "";
			$device["snmp_username"] = "";
			$device["snmp_password"] = "";
			$device["snmp_auth_protocol"] = "";
			$device["snmp_priv_passphrase"] = "";
			$device["snmp_priv_protocol"] = "";
			$device["snmp_context"] = "";
			$device["snmp_version"] = "";
			$device["snmp_port"] = "";
			$device["hostname"] = "None";
		}

		if ($poller_action_id == 0) {
			if (($device["snmp_version"] < 1) || ($device["snmp_version"] > 3) ||
				($device["snmp_community"] == "" && $device["snmp_version"] != 3)) {
				return;
			}
		}

		$rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);

		return "($local_data_id, " . $device["poller_id"] . ", " . $device["id"] . ", $poller_action_id,'" . $device["hostname"] . "',
			'" . $device["snmp_community"]       . "', '" . $device["snmp_version"]       . "', '" . $device["snmp_timeout"] . "',
			'" . $device["snmp_username"]        . "', '" . $device["snmp_password"]      . "', '" . $device["snmp_auth_protocol"] . "',
			'" . $device["snmp_priv_passphrase"] . "', '" . $device["snmp_priv_protocol"] . "', '" . $device["snmp_context"] . "',
			'" . $device["snmp_port"]            . "', '$data_source_item_name', '"     . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',
			'$num_rrd_items', '$rrd_step', '$rrd_next_step', '$arg1', '$arg2', '$arg3', '1')";
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:88,代码来源:api_poller.php


示例14: rrdtool_function_info

function rrdtool_function_info($data_source_id) {
	global $config;

	/* Get the path to rrdtool file */
	$data_source_path = get_data_source_path($data_source_id, true);

	/* Execute rrdtool info command */
	$cmd_line = " info " . $data_source_path;
	$output = rrdtool_execute($cmd_line, RRDTOOL_OUTPUT_NULL, RRDTOOL_OUTPUT_STDOUT);
	if (sizeof($output) == 0) {
		return false;
	}

	/* Parse the output */
	$matches = array();
	$rrd_info = array( 'rra' => array(), "ds" => array() );
	$output = explode("\n", $output);
	foreach ($output as $line) {
		$line = trim($line);
		if (preg_match("/^ds\[(\S+)\]\.(\S+) = (\S+)$/", $line, $matches)) {
			$rrd_info["ds"][$matches[1]][$matches[2]] = $matches[3];
		} elseif (preg_match("/^rra\[(\S+)\]\.(\S+)\[(\S+)\]\.(\S+) = (\S+)$/", $line, $matches)) {
			$rrd_info['rra'][$matches[1]][$matches[2]][$matches[3]][$matches[4]] = $matches[5];
		} elseif (preg_match("/^rra\[(\S+)\]\.(\S+) = (\S+)$/", $line, $matches)) {
			$rrd_info['rra'][$matches[1]][$matches[2]] = $matches[3];
		} elseif (preg_match("/^(\S+) = \"(\S+)\"$/", $line, $matches)) {
			$rrd_info[$matches[1]] = $matches[2];
		} elseif (preg_match("/^(\S+) = (\S+)$/", $line, $matches)) {
			$rrd_info[$matches[1]] = $matches[2];
		}
	}
	$output = "";
	$matches = array();

	/* Return parsed values */
	return $rrd_info;

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


示例15: 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['consolidatio 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_data_source_title函数代码示例发布时间:2022-05-15
下一篇:
PHP get_data_source_item_name函数代码示例发布时间: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