Skip to content

Commit

Permalink
QA: More fixups on Aggregate totals
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Nov 20, 2023
1 parent 06ad4bd commit 914f187
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/graph_variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,14 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
break;
case 'aggregate_peak':
case 'aggregate_max':
case 'aggregate_sum_peak':
if (cacti_sizeof($local_data_array)) {
$nth_cache = nth_percentile($local_data_array, $graph_start, $graph_end, $percentile, 0, true);
}

break;
case 'aggregate_current':
case 'aggregate_current_peak':
$local_data_array = array();
if (!empty($graph_item['data_source_name'])) {
foreach ($graph_items as $graph_element) {
Expand All @@ -497,8 +499,14 @@ function variable_nth_percentile(&$regexp_match_array, &$graph, &$graph_item, &$
}
}

if (cacti_sizeof($local_data_array)) {
$nth_cache = nth_percentile($local_data_array, $graph_start, $graph_end, $percentile);
if ($type == 'aggregate_current') {
if (cacti_sizeof($local_data_array)) {
$nth_cache = nth_percentile($local_data_array, $graph_start, $graph_end, $percentile);
}
} else {
if (cacti_sizeof($local_data_array)) {
$nth_cache = nth_percentile($local_data_array, $graph_start, $graph_end, $percentile, 0, true);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rrd.php
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ function rrdtool_function_graph($local_graph_id, $rra_id, $graph_data_array, $rr
$graph_variables[$field_name][$graph_item_id] = rrd_substitute_host_query_data($graph_variables[$field_name][$graph_item_id], $graph, $graph_item);

/* 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_peak|aggregate):(\d)?\|/', $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
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_sum_peak|aggregate_current|aggregate_current_peak|aggregate_peak|aggregate):(\d)?\|/', $graph_variables[$field_name][$graph_item_id], $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$search[] = $match[0];
$value = variable_nth_percentile($match, $graph, $graph_item, $graph_items, $graph_start, $graph_end);
Expand Down

0 comments on commit 914f187

Please sign in to comment.