Version: Cacti 1.2.5/Linux
When I created a graph that the datasource consolidation function of MAX, the 95th_percentile function return a lower value than the right one. By checked the csv outport file, I confirmed that the 95th_percentile function only use the avg cf datasource to calculate result.
I check the source code of nth_percentile in lib/graph_variables.php , Line 32-36:
function nth_percentile($local_data_ids, $start_seconds, $end_seconds, $percentile = 95, $resolution = 0, $peak = false) {
$stats = json_decode(rrdtool_function_stats($local_data_ids, $start_seconds, $end_seconds, $percentile, $resolution, $peak), true);
}
In line 129-139, the $stats have complete description of MAX and AVG:
if (cacti_sizeof($fetch_array)) {
$stats['avg'] = nth_percentile_fetch_statistics($percentile, $local_data_ids, $fetch_array, 'AVERAGE');
}
if (cacti_sizeof($fetch_array_max)) {
$stats['peak'] = nth_percentile_fetch_statistics($percentile, $local_data_ids, $fetch_array_max, 'MAX');
}
return json_encode($stats);
For some unknown reason, function nth_percentile ignore the $peak parameter , directly return the 'avg' value. I think it is a bug of function nth_percentile, I modifed it in lib/graph_varialbes.php line 32-36:
function nth_percentile($local_data_ids, $start_seconds, $end_seconds, $percentile = 95, $resolution = 0, $peak = false) {
$stats = json_decode(rrdtool_function_stats($local_data_ids, $start_seconds, $end_seconds, $percentile, $resolution, $peak), true);
if ($peak) {
return $stats['peak'];
} else {
return $stats['avg'];
}
}
In Cacti 1.2.6/CentOS 7.6, I have confirmed the modification is ok and get the right value of 95th_percentile of MAX_cf datasource.
Version: Cacti 1.2.5/Linux
When I created a graph that the datasource consolidation function of MAX, the 95th_percentile function return a lower value than the right one. By checked the csv outport file, I confirmed that the 95th_percentile function only use the avg cf datasource to calculate result.
I check the source code of nth_percentile in lib/graph_variables.php , Line 32-36:
function nth_percentile($local_data_ids, $start_seconds, $end_seconds, $percentile = 95, $resolution = 0, $peak = false) {
$stats = json_decode(rrdtool_function_stats($local_data_ids, $start_seconds, $end_seconds, $percentile, $resolution, $peak), true);
}
In line 129-139, the $stats have complete description of MAX and AVG:
For some unknown reason, function nth_percentile ignore the $peak parameter , directly return the 'avg' value. I think it is a bug of function nth_percentile, I modifed it in lib/graph_varialbes.php line 32-36:
function nth_percentile($local_data_ids, $start_seconds, $end_seconds, $percentile = 95, $resolution = 0, $peak = false) {
$stats = json_decode(rrdtool_function_stats($local_data_ids, $start_seconds, $end_seconds, $percentile, $resolution, $peak), true);
}
In Cacti 1.2.6/CentOS 7.6, I have confirmed the modification is ok and get the right value of 95th_percentile of MAX_cf datasource.