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

Rounding causes errors with variable substitution #4548

Closed
densenator opened this issue Feb 8, 2022 · 14 comments
Closed

Rounding causes errors with variable substitution #4548

densenator opened this issue Feb 8, 2022 · 14 comments
Labels
bug Undesired behaviour unverified Some days we don't have a clue

Comments

@densenator
Copy link

densenator commented Feb 8, 2022

I get some errors in my log file. Please help me

08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1949]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())

08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203
08.02.2022 10:21:09 - CMDPHP PHP ERROR Backtrace: (/graph_realtime.php[218]:rrdtool_function_graph(), /lib/rrd.php[1583]:rrd_substitute_host_query_data(), /lib/rrd.php[2515]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())
08.02.2022 10:21:09 - ERROR PHP DEPRECATED: Implicit conversion from float 2741440.6 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203

Desktop (please complete the following information)

  • OS: debian 11.2.0

  • php 8.1

  • Apache 2.4.52

  • 10.5.12-MariaDB-0+deb11u1 Debian 11

  • installed on root directory instead of cacti
    -cacti Version 1.2.20

  • Browser [e.g. chrome, safari]

  • chrome 98.0.4758.82

@densenator densenator added bug Undesired behaviour unverified Some days we don't have a clue labels Feb 8, 2022
@TheWitness
Copy link
Member

Change the command from intval() to floor() and see if the problem goes away. It's here:

        $allindex    = ($elements - 1) * $p;
        $intvalindex = floor($allindex);
        $floatval    = $allindex - $intvalindex;

TheWitness added a commit that referenced this issue Feb 8, 2022
CMDPHP PHP ERROR Backtrace and other errors
@TheWitness
Copy link
Member

I committed the update.

@densenator
Copy link
Author

Not fixed.

09.02.2022 11:49:29 - CMDPHP PHP ERROR Backtrace: (/data_templates.php[44]:form_save(), /data_templates.php[253]:push_out_data_source(), /lib/template.php[221]:update_data_source_title_cache_from_template(), /lib/variables.php[37]:update_data_source_title_cache(), /lib/variables.php[99]:get_data_source_title(), /lib/functions.php[2449]:expand_title(), /lib/variables.php[234]:substitute_host_data(), /lib/variables.php[313]:get_uptime(), /lib/functions.php[5181]:get_daysfromtime(), /lib/functions.php[5203]:CactiErrorHandler())

09.02.2022 11:49:29 - ERROR PHP DEPRECATED: Implicit conversion from float 59626.9 to int loses precision in file: /var/www/html/lib/functions.php on line: 5203

@TheWitness
Copy link
Member

What's on line 5203 in your version?

@densenator
Copy link
Author

    foreach ($mods as $index => $mod) {
            if ($mod > 0 || $secs) {
                    if ($time >= $mod) {
                            if ($mod < 1) {
                                    $mod = 1;
                            }
                            $val   = floor($time/$mod);

5203 - $time %= $mod;
} else {
$val = 0;
}

                    if ($all || $val > 0) {
                            $result .= padleft($pad, $val, 2) . $text['prefix'] . $text[$index] . $text['suffix'];
                            $all = true;
                    }
            }
    }

@TheWitness
Copy link
Member

In my version of lib/functions.php $time %= $mod; is line 5269. Can you confirm?

TheWitness added a commit that referenced this issue Feb 9, 2022
Though the line numbers are not adding up, trying to get this resolved.
@TheWitness
Copy link
Member

I did another update following your back-trace and not the line numbers since they don't even match on the 1.2.x branch.

@densenator
Copy link
Author

Nope. I changed this to $time = floor($mod);
and it is solved my errors.
That's right?

@TheWitness
Copy link
Member

Well, that's one, but I also looked at the backtrace and what is happening is that the hosts sysUptimeInstance was being divided by 100, which is proper, and that converted the "time" value that was sent to the next function was a float, which having a modulus on a float could also throw the loss of precision error. So, I converted it to an integer (I think). You need to make the next update and see if the backtraces go away.

@TheWitness
Copy link
Member

TheWitness commented Feb 9, 2022

I may have to add use intval() instead of floor() or round(). You need to continue to test. I don't have a PHP8.1 env at the moment.

@TheWitness
Copy link
Member

Let's not mess with tickets. I'm only caring about 1.2.x in this ticket.

@TheWitness
Copy link
Member

Right now, I'm not even working on 1.3 tickets. @netniV and I have to get it back into shape after the 1.2.20 release.

@Cacti Cacti deleted a comment from densenator Feb 9, 2022
TheWitness added a commit that referenced this issue Feb 9, 2022
@densenator
Copy link
Author

I'm sorry.
Ok, i'm downgraded and confirmed that i don't view errors!
Thank you

@TheWitness
Copy link
Member

Good to hear. I'll look at your issue on Import as well.

@netniV netniV changed the title CMDPHP PHP ERROR Backtrace and other errors Rounding causes errors with variable substitution Apr 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour unverified Some days we don't have a clue
Projects
None yet
Development

No branches or pull requests

2 participants