Are all_max_peak percentile calculations wrong?

Florian Roscher <[email protected]>
Newsgroups gmane.network.cacti.user
Message-ID <[email protected]>
Hello,

as far as I checked and understood the source code the
calculations for 'all_max_peak' are wrong currently.

For type 'max' as well as 'all_max_peak' function 
nth_percentile() is called with one $local_data_id,
returning a nth_percentile for the given datasource as
well as a calculated field 'nth_percentile_maximum'.

When using 'max', this field 'nth_percentile_maximum' is
used and this looks right for me.

When using 'all_max_peak', the nth_cache is iterated, seeking
for a maximum. But within each iteration the nth_percentile_maximum
is used which should be the same for every local_data_id of that 
RRD. I think the iteration should seek for the maximum of the
n'th percentiles of the respective data sources.


The following patch makes that happen:

root@cacti:/var/www/cacti_test# diff -u lib/graph_variables.php.20121008-dist  lib/graph_variables.php
--- lib/graph_variables.php.20121008-dist	2012-10-25 15:18:56.000000000 +0200
+++ lib/graph_variables.php	2012-10-25 15:58:42.000000000 +0200
@@ -366,8 +366,8 @@
 	}elseif ($regexp_match_array[4] == "all_max_peak") {
 		for ($t=0;($t<count($graph_items));$t++) {
 			if ((preg_match("/(AREA|STACK|LINE[123])/", $graph_item_types{$graph_items[$t]["graph_type_id"]})) && (!empty($graph_items[$t]["data_template_rrd_id"]))) {
-				if (! empty($nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"])) {
-					$local_nth = $nth_cache{$graph_items[$t]["local_data_id"]}["nth_percentile_maximum"];
+				if (! empty($nth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]})) {
+					$local_nth = $nth_cache{$graph_items[$t]["local_data_id"]}{$graph_items[$t]["data_source_name"]};
 					$local_nth = ($regexp_match_array[2] == "bits") ? $local_nth * 8 : $local_nth;
 					$local_nth /= pow(10,intval($regexp_match_array[3]));


Is anyone able and willing to comment on this, check 
my investigations or correct me?


Regards
Florian



-- 
  Florian Roscher                          private: [email protected]
                                            Debian: [email protected] 
PGP Key / ID: 1024D/B4071A65
Fingerprint : F9AB 00C1 3E3A 8125 DD3F  DF1C DF79 A374 B407 1A65

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.