mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-08 21:16:17 +09:00
updates for Bandwidth and Nth Percentile
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/branches/BRANCH_0_8_6/cacti@4081 860744bd-22fc-0310-8c96-e9fe5004b5ca
This commit is contained in:
1 parent
a340320406
commit
9cfdcdf7d6
2 files changed
+40
-3
No files matched your search
+18
-2
@@ -81,17 +81,33 @@ if (!empty($_GET["show_source"])) {
|
||||
|
||||
$graph_info = db_fetch_row("SELECT * FROM graph_templates_graph WHERE local_graph_id='" . $_REQUEST["local_graph_id"] . "'");
|
||||
|
||||
$xport_array = rrdtool_function_xport($_GET["local_graph_id"], $_GET["rra_id"], $graph_data_array);
|
||||
/* for bandwidth, NThPercentile */
|
||||
$xport_meta = array();
|
||||
|
||||
$xport_array = rrdtool_function_xport($_GET["local_graph_id"], $_GET["rra_id"], $graph_data_array, &$xport_meta);
|
||||
|
||||
if (is_array($xport_array["meta"])) {
|
||||
print '"Title:","' . $xport_array["meta"]["title_cache"] . '"' . "\n";
|
||||
print '"Vertical Label:","' . $xport_array["meta"]["vertical_label"] . '"' . "\n";
|
||||
print '"Start Date:","' . date("Y-m-d H:i:s", $xport_array["meta"]["start"]) . '"' . "\n";
|
||||
print '"End Date:","' . date("Y-m-d H:i:s", $xport_array["meta"]["end"]) . '"' . "\n";
|
||||
print '"Interval Time:","' . $xport_array["meta"]["step"] . '"' . "\n";
|
||||
print '"Step:","' . $xport_array["meta"]["step"] . '"' . "\n";
|
||||
print '"Total Rows:","' . $xport_array["meta"]["rows"] . '"' . "\n";
|
||||
print '"Graph ID:","' . $xport_array["meta"]["local_graph_id"] . '"' . "\n";
|
||||
print '"Host ID:","' . $xport_array["meta"]["host_id"] . '"' . "\n";
|
||||
|
||||
if (isset($xport_meta["NThPercent"])) {
|
||||
foreach($xport_meta["NThPercent"] as $item) {
|
||||
print '"NThPercent:","' . $item["value"] . '","' . $item["text_format"] . '"' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xport_meta["Bandwidth"])) {
|
||||
foreach($xport_meta["Bandwidth"] as $item) {
|
||||
print '"Bandwidth:","' . $item["value"] . '","' . $item["text_format"] . '"' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
print '""' . "\n";
|
||||
|
||||
$header = '"Date"';
|
||||
|
||||
+22
-1
@@ -1137,7 +1137,7 @@ function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rr
|
||||
}
|
||||
}
|
||||
|
||||
function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, $rrd_struc = array()) {
|
||||
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");
|
||||
@@ -1204,6 +1204,20 @@ function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, $rr
|
||||
|
||||
$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,
|
||||
@@ -1359,15 +1373,21 @@ function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, $rr
|
||||
|
||||
/* 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)?\|/", $xport_variables[$field_name][$xport_item_id], $matches, PREG_SET_ORDER)) {
|
||||
$k = 0;
|
||||
foreach ($matches as $match) {
|
||||
$xport_variables[$field_name][$xport_item_id] = str_replace($match[0], variable_nth_percentile($match, $xport_item, $xport_items, $graph_start, $graph_end), $xport_variables[$field_name][$xport_item_id]);
|
||||
$xport_meta["NThPercent"][$k][$field_name] =$xport_variables[$field_name][$xport_item_id];
|
||||
$k++;
|
||||
}
|
||||
}
|
||||
|
||||
/* bandwidth summation */
|
||||
if (preg_match_all("/\|sum:(\d|auto):(current|total|atomic):(\d):(\d+|auto)\|/", $xport_variables[$field_name][$xport_item_id], $matches, PREG_SET_ORDER)) {
|
||||
$k = 0;
|
||||
foreach ($matches as $match) {
|
||||
$xport_variables[$field_name][$xport_item_id] = str_replace($match[0], variable_bandwidth_summation($match, $xport_item, $xport_items, $graph_start, $graph_end, $rra["steps"], $ds_step), $xport_variables[$field_name][$xport_item_id]);
|
||||
$xport_meta["Bandwidth"][$k][$field_name] = $xport_variables[$field_name][$xport_item_id];
|
||||
$k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1519,6 +1539,7 @@ function rrdtool_function_xport($local_graph_id, $rra_id, $xport_data_array, $rr
|
||||
|
||||
$xport_array = rrdxport2array(rrdtool_execute("xport $xport_opts$xport_defs$txt_xport_items", false, $output_flag, $rrd_struc));
|
||||
|
||||
/* add host and graph information */
|
||||
$xport_array["meta"]["title_cache"] = $graph["title_cache"];
|
||||
$xport_array["meta"]["vertical_label"] = $graph["vertical_label"];
|
||||
$xport_array["meta"]["local_graph_id"] = $local_graph_id;
|
||||
|
||||
Reference in new issue
Block a user