Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When viewing raw graph data via the GUI, values are not always calculated correctly #3355

Closed
frontierliu opened this issue Mar 17, 2020 · 1 comment
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@frontierliu
Copy link
Contributor

frontierliu commented Mar 17, 2020

Version: Cacti 1.2.10
OS: CentOS 7

20200317115119

When export graph data to html page, It is always base on base_value 1024,not 1000 or any other user defined in graph template. So, when the data is traffic, caculating are not accurate. as below:
20200311112749

In fact,the traffic data were above 7.5G in peak time.

Explore :
I explore code of graph_xport.php , line 214:
print "<td class='right'>" . trim(number_format_i18n(round($row['col' . $i],3))) . '</td>';
the function number_format_i18n() is defined in include/global_languages.php, line 688:
function number_format_i18n($number, $decimals = 0, $baseu = 1024) {
Obivious it has default base_value =1024, but in graph_xport.php ,the base_value parameter is ignored and always defaut to 1024.

How to fix:
juse modify the code of graph_xport.php, line 214 , as below:

diff --git a/usr/local/github/cacti/graph_xport.php b/graph_xport.php
index 0435ba6..fdd325a 100644
--- a/usr/local/github/cacti/graph_xport.php
+++ b/graph_xport.php
@@ -211,7 +211,7 @@ if (isset($xport_array['data']) && is_array($xport_array['data'])) {
                        print "<tr><td class='left'>" . date('Y-m-d H:i:s', (isset($row['timestamp']) ? $row['timestamp'] : $xport_array['meta']['start'] + $j*$xport_array['meta']['step'])) . "</td>";
                        for ($i = 1; $i <= $xport_array['meta']['columns']; $i++) {
                                if ($row['col' . $i] > 1) {
-                                       print "<td class='right'>" . trim(number_format_i18n(round($row['col' . $i],3))) . '</td>';
+                                       print "<td class='right'>" . trim(number_format_i18n(round($row['col' . $i],3),2,$graph_info['base_value'])) . '</td>';
                                } elseif($row['col' . $i] == 0) {
                                        print "<td class='right'>-</td>";
                                } else {

after modify graph_xport.php, It displays correct.
20200311112420

@frontierliu frontierliu changed the title minor bug about base_value in graph_xport.php and how to resolve minor bug about base_value in graph_xport.php and fixed Mar 17, 2020
@TheWitness
Copy link
Member

Pull request againt 1.2.x branch?

TheWitness added a commit that referenced this issue Mar 17, 2020
Resolved in pulle request #3356
@TheWitness TheWitness changed the title minor bug about base_value in graph_xport.php and fixed Minor bug about base_value in graph_xport.php and fixed Mar 17, 2020
@TheWitness TheWitness added bug Undesired behaviour resolved A fixed issue labels Mar 17, 2020
@TheWitness TheWitness added this to the 1.2.11 milestone Mar 17, 2020
@netniV netniV changed the title Minor bug about base_value in graph_xport.php and fixed When viewing raw graph data via the GUI, values are not always calculated correctly Apr 5, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants