0) { /* Create hash of ds_item_name => array or fetch_array indexes */ /* this is used to later sum, max and total the data sources used on the graph */ /* Loop fetch array index */ $dsi_name_to_id = array(); reset($fetch_array); for ($i=0; $i $id_array ) { $sum_array["data_source_names"][$i] = $ds_name; foreach ($id_array as $id) { $fetch_id = array_search($ds_name,$fetch_array[$id]["data_source_names"]); /* Sum up like ds names */ for ($j=0; $j 99)) { /* error Nth Percentile variable is incorrect */ return -1; } /* Get the Nth percentile values */ if (($regexp_match_array[4] == "current") || ($regexp_match_array[4] == "max")) { $nth_cache{$graph_item["local_data_id"]} = nth_percentile($graph_item["local_data_id"], $graph_start, $graph_end, $regexp_match_array[1]); }elseif (($regexp_match_array[4] == "total") || ($regexp_match_array[4] == "total_peak") || ($regexp_match_array[4] == "all_max_current") || ($regexp_match_array[4] == "all_max_peak")) { for ($t=0;($t $nth) { $nth = $local_nth; } } } } }elseif ($regexp_match_array[4] == "all_max_peak") { for ($t=0;($t $nth) { $nth = $local_nth; } } } } }elseif ($regexp_match_array[4] == "aggregate") { if (! empty($nth_cache{0}["nth_percentile_aggregate_total"])) { $local_nth = $nth_cache{0}["nth_percentile_aggregate_total"]; $local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth; $local_nth /= pow(10,intval($regexp_match_array[3])); $nth = $local_nth; } }elseif ($regexp_match_array[4] == "aggregate_max") { if (! empty($nth_cache{0}["nth_percentile_aggregate_max"])) { $local_nth = $nth_cache{0}["nth_percentile_aggregate_max"]; $local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth; $local_nth /= pow(10,intval($regexp_match_array[3])); $nth = $local_nth; } }elseif ($regexp_match_array[4] == "aggregate_sum") { if (! empty($nth_cache{0}["nth_percentile_aggregate_sum"])) { $local_nth = $nth_cache{0}["nth_percentile_aggregate_sum"]; $local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth; $local_nth /= pow(10,intval($regexp_match_array[3])); $nth = $local_nth; } } /* determine the floating point precision */ if (is_numeric($regexp_match_array[5])) { $round_to = $regexp_match_array[5]; }else{ $round_to = 2; } /* return the final result and round off to two decimal digits */ return round($nth, $round_to); } /* variable_bandwidth_summation - given a bandwidth summation variable, calculate the summation and format it for display on the graph @arg $regexp_match_array - the array that contains each argument in the bandwidth summation variable. it should be formatted like so: $arr[0] // full variable string $arr[1] // power of 10 divisor or 'auto' $arr[2] // current, total $arr[3] // digits of floating point precision $arr[4] // seconds to perform the calculation for or 'auto' @arg $graph_item - an array that contains the current graph item @arg $graph_items - an array that contains all graph items @arg $graph_start - the start time to use for the data calculation. this value can either be absolute (unix timestamp) or relative (to now) @arg $graph_end - the end time to use for the data calculation. this value can either be absolute (unix timestamp) or relative (to now) @arg $seconds_between_graph_updates - the number of seconds between each update on the graph which varies depending on the RRA in use @arg $rra_step - how many periods each sample in the RRA counts for, values above '1' result in an averaged summation @arg $ds_step - how many seconds each period represents @returns - a string containg the bandwidth summation suitable for placing on the graph */ function variable_bandwidth_summation(&$regexp_match_array, &$graph_item, &$graph_items, $graph_start, $graph_end, $rra_step, $ds_step) { global $graph_item_types; if (sizeof($regexp_match_array) == 0) { return 0; } if (is_numeric($regexp_match_array[4])) { $summation_timespan_start = -$regexp_match_array[4]; }else{ $summation_timespan_start = $graph_start; } if ($regexp_match_array[2] == "current") { $summation_cache{$graph_item["local_data_id"]} = bandwidth_summation($graph_item["local_data_id"], $summation_timespan_start, $graph_end, $rra_step, $ds_step); }elseif ($regexp_match_array[2] == "total") { for ($t=0;($t