Cacti / plugin_reportit

ReportIt Plugin for Cacti
GNU General Public License v2.0
7 stars 9 forks source link

PHP Parse error #42

Closed gmourani closed 5 years ago

gmourani commented 6 years ago

Hello,

Another bug with upcoming version 1.0.2 installed today September 06 2018. This is what I can see in the Apache log file:

[Thu Sep 06 13:33:02 2018] [error] [client 192.168.2.147] PHP Parse error: syntax error, unexpected '|' in /var/www/html/cacti/plugins/reportit/lib/funct_calculate.php(513) : eval()'d code on line 1, referer: https://192.168.2.227/cacti/plugins/reportit/reports.php

Regards,

netniV commented 6 years ago

try adding cacti_log("\$result = $formula;"); just before the eval to see what the evaluation string is.

gmourani commented 6 years ago

Same result, here the Apache log file:

[Thu Sep 06 14:01:19 2018] [error] [client 192.168.2.147] PHP Parse error: syntax error, unexpected '|' in /var/www/html/cacti/plugins/reportit/lib/funct_calculate.php(514) : eval()'d code on line 1, referer: https://192.168.2.227/cacti/plugins/reportit/reports.php

Regards,

netniV commented 6 years ago

Yeah, there will be a new line in the cacti.log file though.

gmourani commented 6 years ago

2018/09/06 14:01:21 - CMDPHP $result = 0/1000000000100; 2018/09/06 14:01:21 - CMDPHP $result = 0/1000000000100; 2018/09/06 14:01:21 - CMDPHP $result = f_dot( $data[$rra_index][$i], $cache[$i][2][$rra_index], 1000000000/880/100); 2018/09/06 14:01:21 - CMDPHP $result = f_dot( $data[$rra_index][$i], $cache[$i][2][$rra_index], 1000000000/880/100); 2018/09/06 14:01:21 - CMDPHP $result = f_max($data[$rra_index][$i], $cache[$i][0][$rra_index])8; 2018/09/06 14:01:21 - CMDPHP $result = f_max($data[$rra_index][$i], $cache[$i][0][$rra_index])8; 2018/09/06 14:01:21 - ERROR PHP PARSE in Plugin 'reportit': syntax error, unexpected '|' in file: /var/www/html/cacti/plugins/reportit/lib/funct_calculate.php(514) : eval()'d code on line: 1 2018/09/06 14:01:21 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler)(/lib/functions.php: 4628 cacti_debug_backtrace) 2018/09/06 14:01:21 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'reportit'

netniV commented 6 years ago

There doesn't look to be anything wrong at first glance. Maybe @browniebraun will know better.

netniV commented 6 years ago

Just to be sure, I did the following test using a quick mock up:

php -a
Interactive mode enabled

php > function f_max($a,$b) { return $a<$b?$b:$a; }
php > $i = 3;
php > $rra_index = 5;
php > $cache = array(3=>array(0 => array(5=>2)));
php > $data = array(5=>array(3=>1));
php > $result = f_max($data[$rra_index][$i], $cache[$i][0][$rra_index])*8;
php > echo $result;
16

Code is valid code so maybe it's something with the f_max() function

gmourani commented 6 years ago

The only place where I use the f_max() function is to calculate the maximum load on my network interfaces, here the calculation formula used -> f_max*8.

screen shot 2018-09-06 at 2 38 12 pm
browniebraun commented 6 years ago

Reduce the number of data items assigned to a report config to a single entry and then run the report in debug mode using the CLI. php runtime.php -v --debug YOUR_REPORT_ID > report.log

And please ensure that you are using the latest code. Using my lab I can verify that f_max is working faultlessly.

gmourani commented 6 years ago

I can't reduce the number of data items assigned to my report because when running the command in CLI, it still re-add the removed data items and disable the reportit plugin !

So, I've decided to create a new one called test, add just one data item on it and run it from CLI. The result is that all data items present on first report was copied into the new one (the test report) during command execution in CLI and this disabled the reportit plugin again!!

So if I try to see the so called test report after re-enabling the reportit plugin, it look identical to my first report because same data items were copied from first report to the second report !

netniV commented 5 years ago

That will likely be because you ahve the "Auto Generated Data Items" flag set. Unset that flag, remove the DS's you don't want, try again. (My knowledge of this plugin is improving!)

netniV commented 5 years ago

@gmourani Any update on this?