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

PHP get_associated_rras函数代码示例

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

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



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

示例1: rrdtool_function_graph

function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rrd_struc = array()) {
	global $config;

	include_once($config["library_path"] . "/cdef.php");
	include_once($config["library_path"] . "/graph_variables.php");
	include($config["include_path"] . "/config_arrays.php");

	/* before we do anything; make sure the user has permission to view this graph,
	if not then get out */
	if ((read_config_option("global_auth") == "on") && (isset($_SESSION["sess_user_id"]))) {
		$access_denied = !(is_graph_allowed($local_graph_id));

		if ($access_denied == true) {
			return "GRAPH ACCESS DENIED";
		}
	}

	/* find the step and how often this graph is updated with new data */
	$ds_step = db_fetch_cell("select
		data_template_data.rrd_step
		from data_template_data,data_template_rrd,graph_templates_item
		where graph_templates_item.task_item_id=data_template_rrd.id
		and data_template_rrd.local_data_id=data_template_data.local_data_id
		and graph_templates_item.local_graph_id=$local_graph_id
		limit 0,1");
	$ds_step = empty($ds_step) ? 300 : $ds_step;

	/* if no rra was specified, we need to figure out which one RRDTool will choose using
	 * "best-fit" resolution fit algorithm */
	if (empty($rra_id)) {
		if ((empty($graph_data_array["graph_start"])) || (empty($graph_data_array["graph_end"]))) {
			$rra["rows"] = 600;
			$rra["steps"] = 1;
			$rra["timespan"] = 86400;
		}else{
			/* get a list of RRAs related to this graph */
			$rras = get_associated_rras($local_graph_id);

			if (sizeof($rras) > 0) {
				foreach ($rras as $unchosen_rra) {
					/* the timespan specified in the RRA "timespan" field may not be accurate */
					$real_timespan = ($ds_step * $unchosen_rra["steps"] * $unchosen_rra["rows"]);

					/* make sure the current start/end times fit within each RRA's timespan */
					if ( (($graph_data_array["graph_end"] - $graph_data_array["graph_start"]) <= $real_timespan) && ((time() - $graph_data_array["graph_start"]) <= $real_timespan) ) {
						/* is this RRA better than the already chosen one? */
						if ((isset($rra)) && ($unchosen_rra["steps"] < $rra["steps"])) {
							$rra = $unchosen_rra;
						}else if (!isset($rra)) {
							$rra = $unchosen_rra;
						}
					}
				}
			}

			if (!isset($rra)) {
				$rra["rows"] = 600;
				$rra["steps"] = 1;
			}
		}
	}else{
		$rra = db_fetch_row("select timespan,rows,steps from rra where id=$rra_id");
	}

	$seconds_between_graph_updates = ($ds_step * $rra["steps"]);

	$graph = db_fetch_row("select
		graph_local.host_id,
		graph_local.snmp_query_id,
		graph_local.snmp_index,
		graph_templates_graph.title_cache,
		graph_templates_graph.vertical_label,
		graph_templates_graph.auto_scale,
		graph_templates_graph.auto_scale_opts,
		graph_templates_graph.auto_scale_log,
		graph_templates_graph.auto_scale_rigid,
		graph_templates_graph.auto_padding,
		graph_templates_graph.base_value,
		graph_templates_graph.upper_limit,
		graph_templates_graph.lower_limit,
		graph_templates_graph.height,
		graph_templates_graph.width,
		graph_templates_graph.image_format_id,
		graph_templates_graph.unit_value,
		graph_templates_graph.unit_exponent_value,
		graph_templates_graph.export
		from graph_templates_graph,graph_local
		where graph_local.id=graph_templates_graph.local_graph_id
		and graph_templates_graph.local_graph_id=$local_graph_id");

	/* lets make that sql query... */
	$graph_items = db_fetch_assoc("select
		graph_templates_item.id as graph_templates_item_id,
		graph_templates_item.cdef_id,
		graph_templates_item.text_format,
		graph_templates_item.value,
		graph_templates_item.hard_return,
		graph_templates_item.consolidation_function_id,
		graph_templates_item.graph_type_id,
		graph_templates_gprint.gprint_text,
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:rrd.php


示例2: rrdtool_function_xport

function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, &$xport_meta, $rrd_struc = array()) {
	global $config, $consolidation_functions;

	include_once($config["library_path"] . "/cdef.php");
	include_once($config["library_path"] . "/graph_variables.php");
	include_once($config["library_path"] . "/xml.php");
	include($config["include_path"] . "/global_arrays.php");

	/* before we do anything; make sure the user has permission to view this graph,
	if not then get out */
	if ((read_config_option("auth_method") != 0) && (isset($_SESSION["sess_user_id"]))) {
		$access_denied = !(is_graph_allowed($local_graph_id));

		if ($access_denied == true) {
			return "GRAPH ACCESS DENIED";
		}
	}

	/* find the step and how often this graph is updated with new data */
	$ds_step = db_fetch_cell("select
		data_template_data.rrd_step
		from (data_template_data,data_template_rrd,graph_templates_item)
		where graph_templates_item.task_item_id=data_template_rrd.id
		and data_template_rrd.local_data_id=data_template_data.local_data_id
		and graph_templates_item.local_graph_id=$local_graph_id
		limit 0,1");
	$ds_step = empty($ds_step) ? 300 : $ds_step;

	/* if no rra was specified, we need to figure out which one RRDTool will choose using
	 * "best-fit" resolution fit algorithm */
	if (empty($rra_id)) {
		if ((empty($xport_data_array["graph_start"])) || (empty($xport_data_array["graph_end"]))) {
			$rra["rows"] = 600;
			$rra["steps"] = 1;
			$rra["timespan"] = 86400;
		}else{
			/* get a list of RRAs related to this graph */
			$rras = get_associated_rras($local_graph_id);

			if (sizeof($rras) > 0) {
				foreach ($rras as $unchosen_rra) {
					/* the timespan specified in the RRA "timespan" field may not be accurate */
					$real_timespan = ($ds_step * $unchosen_rra["steps"] * $unchosen_rra["rows"]);

					/* make sure the current start/end times fit within each RRA's timespan */
					if ( (($xport_data_array["graph_end"] - $xport_data_array["graph_start"]) <= $real_timespan) && ((time() - $xport_data_array["graph_start"]) <= $real_timespan) ) {
						/* is this RRA better than the already chosen one? */
						if ((isset($rra)) && ($unchosen_rra["steps"] < $rra["steps"])) {
							$rra = $unchosen_rra;
						}else if (!isset($rra)) {
							$rra = $unchosen_rra;
						}
					}
				}
			}

			if (!isset($rra)) {
				$rra["rows"] = 600;
				$rra["steps"] = 1;
			}
		}
	}else{
		$rra = db_fetch_row("select timespan,rows,steps from rra where id=$rra_id");
	}

	$seconds_between_graph_updates = ($ds_step * $rra["steps"]);

	/* override: graph start time */
	if ((!isset($graph_data_array["graph_start"])) || ($graph_data_array["graph_start"] == "0")) {
		$graph_start = -($rra["timespan"]);
	}else{
		$graph_start = $graph_data_array["graph_start"];
	}

	/* override: graph end time */
	if ((!isset($graph_data_array["graph_end"])) || ($graph_data_array["graph_end"] == "0")) {
		$graph_end = -($seconds_between_graph_updates);
	}else{
		$graph_end = $graph_data_array["graph_end"];
	}

	$graph = db_fetch_row("select
		graph_local.host_id,
		graph_local.snmp_query_id,
		graph_local.snmp_index,
		graph_templates_graph.title_cache,
		graph_templates_graph.vertical_label,
		graph_templates_graph.slope_mode,
		graph_templates_graph.auto_scale,
		graph_templates_graph.auto_scale_opts,
		graph_templates_graph.auto_scale_log,
		graph_templates_graph.scale_log_units,
		graph_templates_graph.auto_scale_rigid,
		graph_templates_graph.auto_padding,
		graph_templates_graph.base_value,
		graph_templates_graph.upper_limit,
		graph_templates_graph.lower_limit,
		graph_templates_graph.height,
		graph_templates_graph.width,
		graph_templates_graph.image_format_id,
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:rrd.php


示例3: export_tree_graphs_and_graph_html

function export_tree_graphs_and_graph_html($path, $tree_id)
{
    global $colors, $config;
    include_once $config["library_path"] . "/tree.php";
    include_once $config["library_path"] . "/data_query.php";
    /* start the count of graphs */
    $total_graphs_created = 0;
    $exported_files = array();
    $cacti_export_path = read_config_option("path_html_export");
    /* auth check for hosts on the trees */
    $current_user = db_fetch_row("SELECT * FROM user_auth WHERE id=" . read_config_option("export_user_id"));
    if (!export_is_tree_allowed($tree_id)) {
        return 0;
    }
    $sql_join = "LEFT JOIN graph_local ON (graph_templates_graph.local_graph_id=graph_local.id)\n\t\tLEFT JOIN graph_templates ON (graph_templates.id=graph_local.graph_template_id)\n\t\tLEFT JOIN host ON (host.id=graph_local.host_id)\n\t\tLEFT JOIN user_auth_perms ON ((graph_templates_graph.local_graph_id=user_auth_perms.item_id and user_auth_perms.type=1 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (host.id=user_auth_perms.item_id AND user_auth_perms.type=3 AND user_auth_perms.user_id=" . $current_user["id"] . ") OR (graph_templates.id=user_auth_perms.item_id AND user_auth_perms.type=4 AND user_auth_perms.user_id=" . $current_user["id"] . "))";
    $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]);
    $sql_where = empty($sql_where) ? "" : "AND {$sql_where}";
    $graphs = array();
    if ($tree_id == 0) {
        $hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items");
    } else {
        $hosts = db_fetch_assoc("SELECT DISTINCT host_id FROM graph_tree_items WHERE graph_tree_id=" . $tree_id);
    }
    /* get a list of host graphs first */
    if (sizeof($hosts)) {
        foreach ($hosts as $host) {
            $hosts_sql = "SELECT DISTINCT\n\t\t\tgraph_templates_graph.id,\n\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\tgraph_templates_graph.height,\n\t\t\tgraph_templates_graph.width,\n\t\t\tgraph_templates_graph.title_cache,\n\t\t\tgraph_templates.name,\n\t\t\tgraph_local.host_id\n\t\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t\t{$sql_join}\n\t\t\tWHERE ((graph_templates_graph.local_graph_id<>0)\n\t\t\t{$sql_where}\n\t\t\tAND (graph_local.host_id=" . $host["host_id"] . ")\n\t\t\tAND (graph_templates_graph.export='on'))\n\t\t\tORDER BY graph_templates_graph.title_cache";
            $host_graphs = db_fetch_assoc($hosts_sql);
            if (sizeof($host_graphs)) {
                if (sizeof($graphs)) {
                    $graphs = array_merge($host_graphs, $graphs);
                } else {
                    $graphs = $host_graphs;
                }
            }
        }
    }
    /* now get the list of graphs placed within the tree */
    if ($tree_id == 0) {
        $sql_where = "WHERE graph_templates_graph.local_graph_id!=0\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.export='on'";
    } else {
        $sql_where = "WHERE graph_tree_items.graph_tree_id =" . $tree_id . "\n\t\t\t{$sql_where}\n\t\t\tAND graph_templates_graph.local_graph_id!=0\n\t\t\tAND graph_templates_graph.export='on'";
    }
    $non_host_sql = "SELECT\n\t\tgraph_templates_graph.id,\n\t\tgraph_templates_graph.local_graph_id,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates.name,\n\t\tgraph_local.host_id,\n\t\tgraph_tree_items.id AS gtid\n\t\tFROM (graph_tree_items, graph_templates_graph)\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tAND graph_tree_items.local_graph_id = graph_templates_graph.local_graph_id\n\t\tAND graph_templates_graph.export='on'\n\t\tORDER BY graph_templates_graph.title_cache";
    $non_host_graphs = db_fetch_assoc($non_host_sql);
    if (sizeof($non_host_graphs)) {
        if (sizeof($graphs)) {
            $graphs = array_merge($non_host_graphs, $graphs);
        } else {
            $graphs = $non_host_graphs;
        }
    }
    /* open a pipe to rrdtool for writing */
    $rrdtool_pipe = rrd_init();
    /* for each graph... */
    $i = 0;
    if (sizeof($graphs) > 0) {
        foreach ($graphs as $graph) {
            $rras = get_associated_rras($graph["local_graph_id"]);
            /* settings for preview graphs */
            $graph_data_array["graph_height"] = read_config_option("export_default_height");
            $graph_data_array["graph_width"] = read_config_option("export_default_width");
            $graph_data_array["graph_nolegend"] = true;
            $graph_data_array["export"] = true;
            if (read_config_option("export_tree_isolation") == "on") {
                $graph_data_array["export_filename"] = "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
                $export_filename = $cacti_export_path . "/" . $path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
            } else {
                $graph_data_array["export_filename"] = "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
                $export_filename = $cacti_export_path . "/graphs/thumb_" . $graph["local_graph_id"] . ".png";
            }
            if (!array_search($export_filename, $exported_files)) {
                /* add the graph to the exported list */
                array_push($exported_files, $export_filename);
                export_log("Creating Graph '" . $cacti_export_path . $graph_data_array["export_filename"] . "'");
                /* generate the graph */
                rrdtool_function_graph($graph["local_graph_id"], 0, $graph_data_array, $rrdtool_pipe);
                $total_graphs_created++;
                /* generate html files for each graph */
                if (read_config_option("export_tree_isolation") == "on") {
                    export_log("Creating File  '" . $cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html'");
                    $fp_graph_index = fopen($cacti_export_path . "/" . $path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
                } else {
                    export_log("Creating File  '" . $cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html'");
                    $fp_graph_index = fopen($cacti_export_path . "/graph_" . $graph["local_graph_id"] . ".html", "w");
                }
                fwrite($fp_graph_index, HTML_HEADER_TREE);
                /* write the code for the tree at the left */
                draw_html_left_tree($fp_graph_index, $tree_id);
                fwrite($fp_graph_index, HTML_GRAPH_HEADER_ONE_TREE);
                fwrite($fp_graph_index, "<strong>Graph - " . $graph["title_cache"] . "</strong></td></tr>");
                fwrite($fp_graph_index, HTML_GRAPH_HEADER_TWO_TREE);
                fwrite($fp_graph_index, "<td>");
                /* reset vars for actual graph image creation */
                reset($rras);
                unset($graph_data_array);
                /* generate graphs for each rra */
                foreach ($rras as $rra) {
                    $graph_data_array["export"] = true;
                    if (read_config_option("export_tree_isolation") == "on") {
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_export.php


示例4: get_graph_title

	$access_denied = !(is_graph_allowed($_GET["local_graph_id"]));

	if ($access_denied == true) {
		print "<strong><font size='+1' color='FF0000'>ACCESS DENIED</font></strong>"; exit;
	}
}

$graph_title = get_graph_title($_GET["local_graph_id"]);

if ($_REQUEST["view_type"] == "tree") {
	print "<table width='100%' style='background-color: #ffffff; border: 1px solid #ffffff;' align='center' cellpadding='3'>";
}else{
	print "<br><table width='100%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellpadding='3'>";
}

$rras = get_associated_rras($_GET["local_graph_id"]);

switch ($_REQUEST["action"]) {
case 'view':
	?>
	<tr bgcolor='#<?php print $colors["header_panel"];?>'>
		<td colspan='3' class='textHeaderDark'>
			<strong>Viewing Graph</strong> '<?php print $graph_title;?>'
		</td>
	</tr>
	<?php

	$i = 0;
	if (sizeof($rras) > 0) {
	foreach ($rras as $rra) {
		?>
开发者ID:songchin,项目名称:Cacti,代码行数:31,代码来源:graph.php


示例5: rrdtool_function_graph

function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rrdtool_pipe = "", &$xport_meta = array())
{
    global $config, $consolidation_functions;
    include_once $config["library_path"] . "/cdef.php";
    include_once $config["library_path"] . "/graph_variables.php";
    include_once $config['library_path'] . '/boost.php';
    include_once $config['library_path'] . '/xml.php';
    include $config["include_path"] . "/global_arrays.php";
    /* prevent command injection
     * This function prepares an rrdtool graph statement to be executed by the web server.
     * We have to take care, that the attacker does not insert shell code.
     * As some rrdtool parameters accept "Cacti variables", we have to perform the
     * variable substitution prior to vulnerability checks.
     * We will enclose all parameters in quotes and substitute quotation marks within
     * those parameters. 
     */
    /* rrdtool fetches the default font from it's execution environment
     * you won't find that default font on the rrdtool statement itself!
     * set the rrdtool default font via environment variable */
    if (!isset($graph_data_array['export_csv'])) {
        if (read_config_option("path_rrdtool_default_font")) {
            putenv("RRD_DEFAULT_FONT=" . read_config_option("path_rrdtool_default_font"));
        }
    }
    /* before we do anything; make sure the user has permission to view this graph,
    	if not then get out */
    if (!is_graph_allowed($local_graph_id)) {
        return "GRAPH ACCESS DENIED";
    }
    /* check the boost image cache and if we find a live file there return it instead */
    if (!isset($graph_data_array['export_csv']) && !isset($graph_data_array['export_realtime'])) {
        $graph_data = boost_graph_cache_check($local_graph_id, $rra_id, $rrdtool_pipe, $graph_data_array, false);
        if ($graph_data != false) {
            return $graph_data;
        }
    }
    /* find the step and how often this graph is updated with new data */
    $ds_step = db_fetch_cell("SELECT\n\t\tdata_template_data.rrd_step\n\t\tFROM (data_template_data,data_template_rrd,graph_templates_item)\n\t\tWHERE graph_templates_item.task_item_id=data_template_rrd.id\n\t\tAND data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\tAND graph_templates_item.local_graph_id={$local_graph_id}\n\t\tLIMIT 0,1");
    $ds_step = empty($ds_step) ? 300 : $ds_step;
    /* if no rra was specified, we need to figure out which one RRDTool will choose using
     * "best-fit" resolution fit algorithm */
    if (empty($rra_id)) {
        if (empty($graph_data_array["graph_start"]) || empty($graph_data_array["graph_end"])) {
            $rra["rows"] = 600;
            $rra["steps"] = 1;
            $rra["timespan"] = 86400;
        } else {
            /* get a list of RRAs related to this graph */
            $rras = get_associated_rras($local_graph_id);
            if (sizeof($rras) > 0) {
                foreach ($rras as $unchosen_rra) {
                    /* the timespan specified in the RRA "timespan" field may not be accurate */
                    $real_timespan = $ds_step * $unchosen_rra["steps"] * $unchosen_rra["rows"];
                    /* make sure the current start/end times fit within each RRA's timespan */
                    if ($graph_data_array["graph_end"] - $graph_data_array["graph_start"] <= $real_timespan && time() - $graph_data_array["graph_start"] <= $real_timespan) {
                        /* is this RRA better than the already chosen one? */
                        if (isset($rra) && $unchosen_rra["steps"] < $rra["steps"]) {
                            $rra = $unchosen_rra;
                        } else {
                            if (!isset($rra)) {
                                $rra = $unchosen_rra;
                            }
                        }
                    }
                }
            }
            if (!isset($rra)) {
                $rra["rows"] = 600;
                $rra["steps"] = 1;
            }
        }
    } else {
        $rra = db_fetch_row("SELECT timespan,rows,steps FROM rra WHERE id={$rra_id}");
    }
    if (!isset($graph_data_array['export_realtime'])) {
        $seconds_between_graph_updates = $ds_step * $rra["steps"];
    } else {
        $seconds_between_graph_updates = 5;
    }
    $graph = db_fetch_row("SELECT gl.id AS local_graph_id, gl.host_id,\n\t\tgl.snmp_query_id, gl.snmp_index, gtg.title_cache, gtg.vertical_label,\n\t\tgtg.slope_mode, gtg.auto_scale, gtg.auto_scale_opts, gtg.auto_scale_log,\n\t\tgtg.scale_log_units, gtg.auto_scale_rigid, gtg.auto_padding, gtg.base_value,\n\t\tgtg.upper_limit, gtg.lower_limit, gtg.height, gtg.width, gtg.image_format_id,\n\t\tgtg.unit_value, gtg.unit_exponent_value, gtg.export\n\t\tFROM graph_templates_graph AS gtg\n\t\tINNER JOIN graph_local AS gl\n\t\tON gl.id=gtg.local_graph_id\n\t\tWHERE gtg.local_graph_id={$local_graph_id}");
    /* lets make that sql query... */
    $graph_items = db_fetch_assoc("SELECT gti.id AS graph_templates_item_id,\n\t\tgti.cdef_id, gti.text_format, gti.value, gti.hard_return,\n\t\tgti.consolidation_function_id, gti.graph_type_id, gtgp.gprint_text,\n\t\tcolors.hex, gti.alpha, dtr.id AS data_template_rrd_id, dtr.local_data_id,\n\t\tdtr.rrd_minimum, dtr.rrd_maximum, dtr.data_source_name, dtr.local_data_template_rrd_id\n\t\tFROM graph_templates_item AS gti\n\t\tLEFT JOIN data_template_rrd AS dtr\n\t\tON gti.task_item_id=dtr.id\n\t\tLEFT JOIN colors \n\t\tON gti.color_id=colors.id\n\t\tLEFT JOIN graph_templates_gprint AS gtgp\n\t\tON gti.gprint_id=gtgp.id\n\t\tWHERE gti.local_graph_id={$local_graph_id}\n\t\tORDER BY gti.sequence");
    /* variables for use below */
    $graph_defs = "";
    $txt_graph_items = "";
    $text_padding = "";
    $padding_estimate = 0;
    $last_graph_type = "";
    /* override: graph start time */
    if (!isset($graph_data_array["graph_start"]) || $graph_data_array["graph_start"] == "0") {
        $graph_start = -$rra["timespan"];
    } else {
        $graph_start = $graph_data_array["graph_start"];
    }
    /* override: graph end time */
    if (!isset($graph_data_array["graph_end"]) || $graph_data_array["graph_end"] == "0") {
        $graph_end = -$seconds_between_graph_updates;
    } else {
        $graph_end = $graph_data_array["graph_end"];
    }
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:rrd.php


示例6: process_variables

function process_variables($input, $graph_item, $graph_start = 0, $graph_end = 0)
{
    $matches = array();
    $match = "";
    /* Get graph items for the graph */
    $graph_items = db_fetch_assoc("SELECT\n\t\tgraph_templates_item.id AS graph_templates_item_id,\n\t\tgraph_templates_item.cdef_id,\n\t\tgraph_templates_item.text_format,\n\t\tgraph_templates_item.value,\n\t\tgraph_templates_item.hard_return,\n\t\tgraph_templates_item.consolidation_function_id,\n\t\tgraph_templates_item.graph_type_id,\n\t\tgraph_templates_gprint.gprint_text,\n\t\tcolors.hex,\n\t\tdata_template_rrd.id as data_template_rrd_id,\n\t\tdata_template_rrd.local_data_id,\n\t\tdata_template_rrd.rrd_minimum,\n\t\tdata_template_rrd.rrd_maximum,\n\t\tdata_template_rrd.data_source_name,\n\t\tdata_template_rrd.local_data_template_rrd_id\n\t\tFROM graph_templates_item\n\t\tLEFT JOIN data_template_rrd ON (graph_templates_item.task_item_id=data_template_rrd.id)\n\t\tLEFT JOIN colors ON (graph_templates_item.color_id=colors.id)\n\t\tLEFT JOIN graph_templates_gprint on (graph_templates_item.gprint_id=graph_templates_gprint.id)\n\t\tWHERE graph_templates_item.local_graph_id=" . $graph_item["local_graph_id"] . "\n\t\tORDER BY graph_templates_item.sequence");
    /* find the step and how often this graph is updated with new data */
    $ds_step = db_fetch_cell("select\n\t\tdata_template_data.rrd_step\n\t\tfrom (data_template_data,data_template_rrd,graph_templates_item)\n\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\tand data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\tand graph_templates_item.local_graph_id=" . $graph_item["local_graph_id"] . "\n\t\tlimit 0,1");
    $ds_step = empty($ds_step) ? 300 : $ds_step;
    if (empty($graph_start) || empty($graph_end)) {
        $rra["rows"] = 600;
        $rra["steps"] = 1;
        $rra["timespan"] = 86400;
    } else {
        /* get a list of RRAs related to this graph */
        $rras = get_associated_rras($graph_item["local_graph_id"]);
        if (sizeof($rras) > 0) {
            foreach ($rras as $unchosen_rra) {
                /* the timespan specified in the RRA "timespan" field may not be accurate */
                $real_timespan = $ds_step * $unchosen_rra["steps"] * $unchosen_rra["rows"];
                /* make sure the current start/end times fit within each RRA's timespan */
                if ($graph_end - $graph_start <= $real_timespan && time() - $graph_start <= $real_timespan) {
                    /* is this RRA better than the already chosen one? */
                    if (isset($rra) && $unchosen_rra["steps"] < $rra["steps"]) {
                        $rra = $unchosen_rra;
                    } else {
                        if (!isset($rra)) {
                            $rra = $unchosen_rra;
                        }
                    }
                }
            }
        }
        if (!isset($rra)) {
            $rra["rows"] = 600;
            $rra["steps"] = 1;
        }
    }
    $seconds_between_graph_updates = $ds_step * $rra["steps"];
    /* override: graph start time */
    if (!isset($graph_start) || $graph_start == "0") {
        $graph_start = -$rra["timespan"];
    }
    /* override: graph end time */
    if (!isset($graph_end) || $graph_end == "0") {
        $graph_end = -$seconds_between_graph_updates;
    }
    /* Nth percentile */
    if (preg_match_all("/\\|([0-9]{1,2}):(bits|bytes):(\\d):(current|total|max|total_peak|all_max_current|all_max_peak|aggregate_max|aggregate_sum|aggregate_current|aggregate):(\\d)?\\|/", $input, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $input = str_replace($match[0], variable_nth_percentile($match, $graph_item, $graph_items, $graph_start, $graph_end), $input);
        }
    }
    /* bandwidth summation */
    if (preg_match_all("/\\|sum:(\\d|auto):(current|total|atomic):(\\d):(\\d+|auto)\\|/", $input, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $input = str_replace($match[0], variable_bandwidth_summation($match, $graph_item, $graph_items, $graph_start, $graph_end, $rra["steps"], $ds_step), $input);
        }
    }
    return $input;
}
开发者ID:BagusTesa,项目名称:Cacti-ISP-Billing,代码行数:61,代码来源:functions.php


示例7: header

if (!db_fetch_cell_prepared('SELECT local_graph_id FROM graph_templates_graph WHERE local_graph_id = ?', array(get_request_var_request('local_graph_id')))) {
    print "<strong><font class='txtErrorTextBox'>GRAPH DOES NOT EXIST</font></strong>";
    exit;
}
/* take graph permissions into account here */
if (!is_graph_allowed($_REQUEST['local_graph_id'])) {
    header('Location: permission_denied.php');
    exit;
}
$graph_title = get_graph_title($_REQUEST['local_graph_id']);
if ($_REQUEST['view_type'] == 'tree') {
    print "<table width='100%' style='background-color: #ffffff; border: 1px solid #ffffff;' align='center' cellspacing='0' cellpadding='3'>";
} else {
    print "<table width='100%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellspacing='0' cellpadding='3'>";
}
$rras = get_associated_rras($_REQUEST['local_graph_id']);
switch ($_REQUEST['action']) {
    case 'view':
        api_plugin_hook_function('page_buttons', array('lgid' => $_REQUEST['local_graph_id'], 'leafid' => '', 'mode' => 'mrtg', 'rraid' => $_REQUEST['rra_id']));
        ?>
	<tr class='tableHeader'>
		<td colspan='3' class='textHeaderDark'>
			<strong>Viewing Graph</strong> '<?php 
        print htmlspecialchars($graph_title);
        ?>
'
		<script type="text/javascript" >
		$(function() { 
			$('#navigation').show();
			$('#navigation_right').show();
		});
开发者ID:MrWnn,项目名称:cacti,代码行数:31,代码来源:graph.php


示例8: rrdtool_function_xport

function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, &$xport_meta, $rrd_struc = array())
{
    global $config;
    include_once $config["library_path"] . "/cdef.php";
    include_once $config["library_path"] . "/graph_variables.php";
    include_once $config["library_path"] . "/xml.php";
    include $config["include_path"] . "/global_arrays.php";
    /* before we do anything; make sure the user has permission to view this graph,
    	if not then get out */
    if (read_config_option("auth_method") != 0 && isset($_SESSION["sess_user_id"])) {
        $access_denied = !is_graph_allowed($local_graph_id);
        if ($access_denied == true) {
            return "GRAPH ACCESS DENIED";
        }
    }
    /* find the step and how often this graph is updated with new data */
    $ds_step = db_fetch_cell("select\n\t\tdata_template_data.rrd_step\n\t\tfrom (data_template_data,data_template_rrd,graph_templates_item)\n\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\tand data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\tand graph_templates_item.local_graph_id={$local_graph_id}\n\t\tlimit 0,1");
    $ds_step = empty($ds_step) ? 300 : $ds_step;
    /* if no rra was specified, we need to figure out which one RRDTool will choose using
     * "best-fit" resolution fit algorithm */
    if (empty($rra_id)) {
        if (empty($xport_data_array["graph_start"]) || empty($xport_data_array["graph_end"])) {
            $rra["rows"] = 600;
            $rra["steps"] = 1;
            $rra["timespan"] = 86400;
        } else {
            /* get a list of RRAs related to this graph */
            $rras = get_associated_rras($local_graph_id);
            if (sizeof($rras) > 0) {
                foreach ($rras as $unchosen_rra) {
                    /* the timespan specified in the RRA "timespan" field may not be accurate */
                    $real_timespan = $ds_step * $unchosen_rra["steps"] * $unchosen_rra["rows"];
                    /* make sure the current start/end times fit within each RRA's timespan */
                    if ($xport_data_array["graph_end"] - $xport_data_array["graph_start"] <= $real_timespan && time() - $xport_data_array["graph_start"] <= $real_timespan) {
                        /* is this RRA better than the already chosen one? */
                        if (isset($rra) && $unchosen_rra["steps"] < $rra["steps"]) {
                            $rra = $unchosen_rra;
                        } else {
                            if (!isset($rra)) {
                                $rra = $unchosen_rra;
                            }
                        }
                    }
                }
            }
            if (!isset($rra)) {
                $rra["rows"] = 600;
                $rra["steps"] = 1;
            }
        }
    } else {
        $rra = db_fetch_row("select timespan,rows,steps from rra where id={$rra_id}");
    }
    $seconds_between_graph_updates = $ds_step * $rra["steps"];
    /* override: graph start time */
    if (!isset($graph_data_array["graph_start"]) || $graph_data_array["graph_start"] == "0") {
        $graph_start = -$rra["timespan"];
    } else {
        $graph_start = $graph_data_array["graph_start"];
    }
    /* override: graph end time */
    if (!isset($graph_data_array["graph_end"]) || $graph_data_array["graph_end"] == "0") {
        $graph_end = -$seconds_between_graph_updates;
    } else {
        $graph_end = $graph_data_array["graph_end"];
    }
    $graph = db_fetch_row("select\n\t\tgraph_local.host_id,\n\t\tgraph_local.snmp_query_id,\n\t\tgraph_local.snmp_index,\n\t\tgraph_templates_graph.title_cache,\n\t\tgraph_templates_graph.vertical_label,\n\t\tgraph_templates_graph.slope_mode,\n\t\tgraph_templates_graph.auto_scale,\n\t\tgraph_templates_graph.auto_scale_opts,\n\t\tgraph_templates_graph.auto_scale_log,\n\t\tgraph_templates_graph.auto_scale_rigid,\n\t\tgraph_templates_graph.auto_padding,\n\t\tgraph_templates_graph.base_value,\n\t\tgraph_templates_graph.upper_limit,\n\t\tgraph_templates_graph.lower_limit,\n\t\tgraph_templates_graph.height,\n\t\tgraph_templates_graph.width,\n\t\tgraph_templates_graph.image_format_id,\n\t\tgraph_templates_graph.unit_value,\n\t\tgraph_templates_graph.unit_exponent_value,\n\t\tgraph_templates_graph.export\n\t\tfrom (graph_templates_graph,graph_local)\n\t\twhere graph_local.id=graph_templates_graph.local_graph_id\n\t\tand graph_templates_graph.local_graph_id={$local_graph_id}");
    /* lets make that sql query... */
    $xport_items = db_fetch_assoc("select\n\t\tgraph_templates_item.id as graph_templates_item_id,\n\t\tgraph_templates_item.cdef_id,\n\t\tgraph_templates_item.text_format,\n\t\tgraph_templates_item.value,\n\t\tgraph_templates_item.hard_return,\n\t\tgraph_templates_item.consolidation_function_id,\n\t\tgraph_templates_item.graph_type_id,\n\t\tgraph_templates_gprint.gprint_text,\n\t\tcolors.hex,\n\t\tdata_template_rrd.id as data_template_rrd_id,\n\t\tdata_template_rrd.local_data_id,\n\t\tdata_template_rrd.rrd_minimum,\n\t\tdata_template_rrd.rrd_maximum,\n\t\tdata_template_rrd.data_source_name,\n\t\tdata_template_rrd.local_data_template_rrd_id\n\t\tfrom graph_templates_item\n\t\tleft join data_template_rrd on (graph_templates_item.task_item_id=data_template_rrd.id)\n\t\tleft join colors on (graph_templates_item.color_id=colors.id)\n\t\tleft join graph_templates_gprint on (graph_templates_item.gprint_id=graph_templates_gprint.id)\n\t\twhere graph_templates_item.local_graph_id={$local_graph_id}\n\t\torder by graph_templates_item.sequence");
    /* +++++++++++++++++++++++ XPORT OPTIONS +++++++++++++++++++++++ */
    /* override: graph start time */
    if (!isset($xport_data_array["graph_start"]) || $xport_data_array["graph_start"] == "0") {
        $xport_start = -$rra["timespan"];
    } else {
        $xport_start = $xport_data_array["graph_start"];
    }
    /* override: graph end time */
    if (!isset($xport_data_array["graph_end"]) || $xport_data_array["graph_end"] == "0") {
        $xport_end = -$seconds_between_graph_updates;
    } else {
        $xport_end = $xport_data_array["graph_end"];
    }
    /* basic export options */
    $xport_opts = "--start={$xport_start}" . RRD_NL . "--end={$xport_end}" . RRD_NL;
    $xport_defs = "";
    $i = 0;
    $j = 0;
    $nth = 0;
    $sum = 0;
    if (sizeof($xport_items) > 0) {
        foreach ($xport_items as $xport_item) {
            /* mimic the old behavior: LINE[123], AREA, and STACK items use the CF specified in the graph item */
            if ($xport_item["graph_type_id"] == 4 || $xport_item["graph_type_id"] == 5 || $xport_item["graph_type_id"] == 6 || $xport_item["graph_type_id"] == 7 || $xport_item["graph_type_id"] == 8) {
                $xport_cf = $xport_item["consolidation_function_id"];
                /* all other types are based on the AVERAGE CF */
            } else {
                $xport_cf = 1;
            }
            if (!empty($xport_item["local_data_id"]) && !isset($cf_ds_cache[$xport_item["data_template_rrd_id"]][$xport_cf])) {
                /* use a user-specified ds path if one is entered */
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:odp-svn,代码行数:101,代码来源:rrd.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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