ganglia / ganglia-web

Ganglia Web Frontend
BSD 3-Clause "New" or "Revised" License
317 stars 169 forks source link

php error : Call to a member function count() on a non-object in graph.php on line 1176 #343

Open adriansev opened 5 years ago

adriansev commented 5 years ago

Hi! I am trying to export to json a graphic and i get a 500 httpd error and this error message in logs: PHP Fatal error: Call to a member function count() on a non-object in /var/www/html/ganglia/graph.php on line 1176 Does anyone have any idea about this?
Thank you!!!

vvuksan commented 5 years ago

Can you try and update to the latest version and retry. Not really sure what version you are running.

adriansev commented 5 years ago

sorry, i forgot to add, i am on master

adriansev commented 5 years ago

sorry, my mistake, i'm a few commit behind .. i will update my gweb and update the issue asap

adriansev commented 5 years ago

@vvuksan so, i can confirm that i am on master, with all php copied again to /ganglia .. the errors are:
ssl_access_log
XXX.XXX.XXX.XXX - - [22/Mar/2019:23:40:39 +0200] "GET /ganglia/graph.php?h=monitor.spacescience.ro&c=Misc&r=6hr&g=cpu_report&json=1 HTTP/1.1" 500 -
ssl_error_log
[Fri Mar 22 23:40:39.394219 2019] [:error] [pid 26862] [client XXX.XXX.XXX.XXX:34174] PHP Fatal error: Call to a member function count() on a non-object in /var/www/html/ganglia/graph.php on line 1164, referer: https://monitor.spacescience.ro/ganglia/?c=Misc&h=monitor.spacescience.ro&m=cpu_report&r=6hr&s=by%20name&hc=4&mc=3
ssl_request_log
[22/Mar/2019:23:40:39 +0200] 188.25.254.132 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "GET /ganglia/graph.php?h=monitor.spacescience.ro&c=Misc&r=6hr&g=cpu_report&json=1 HTTP/1.1" -

Thank you!!

kevallakhani commented 3 years ago

@vvuksan @adriansev did you figure out how to fix the issue with calling count on null? I am facing the same issue now with rrdtool v1.7 and gweb v3.7.4.

apache2 error.log: PHP Fatal error: Uncaught Error: Call to a member function count() on null in /usr/share/ganglia-webfrontend/graph.php:1164\nStack trace:\n#0 /usr/share/ganglia-webfrontend/graph.php(1681): output_data_to_external_format(' DEF:'a0'='/var...', '-14400s', 'now', 'Aggregate softi...', '/usr/bin/rrdtoo...', NULL, NULL, 1, NULL, NULL, NULL, ' --daemon /tmp/...')\n#1 {main}\n thrown in /usr/share/ganglia-webfrontend/graph.php on line 1164

Thanks for your help!

vvuksan-fastly commented 3 years ago

The best thing to do is run the URL that was being invoked with

&debug=5

It should give you the RRDtool command that is being run. Then execute that on the command line.

kevallakhani commented 3 years ago

@vvuksan Thanks for your prompt reply :) do we need to switch on the debugger in the config somewhere? running the url with &debug=5 still results in internal server error with the same error message about calling count on null at line 1164.

vvuksan-fastly commented 3 years ago

It looks like you may need to just edit graph.php https://github.com/ganglia/ganglia-web/issues/343#issuecomment-705120535 and add e.g.

error_log($command);

then find out what exact command is being executed.

kevallakhani commented 3 years ago

@vvuksan Thanks for that. I tried to extract the command and run it on cmd line to see the output - but I am not sure if it is expected output as well. Btw, I do see this error message in the cmd line output for the xport tool cmd - ERROR: ',' is not a valid function name in , hide-hf=false: command not found among other output that is followed by the status Done and one with status Exit 1

I am not sure if that helps, but I also see another error log in apache2 which says ERROR: Unable to connect to rrdcached: No such file or directory and I am currently running ubuntu18.

Let me know if it doesn't help explain the issue.

kevallakhani commented 3 years ago

A little more looking into it gives an idea that it is probably because of rrdcached is not found because of which the $xml->data is empty which results into the count failing. any ideas about fixing the rrdcached not found issue? Thanks in advance.

vvuksan commented 3 years ago

Do you have this configured in conf.php

$conf['rrdcached_socket'] = "";

?

kevallakhani commented 3 years ago

@vvuksan Yes it is set to $conf['rrdcached_socket'] = '/tmp/rrdcached.limited.sock'; and the file exists in the tmp directory.

vvuksan-fastly commented 3 years ago

Based on the error rrdcached is either not running or there is a mismatch between the socket permissions. You should check the gmetad rrdcached settings and ganglia web settings.

kevallakhani commented 3 years ago

One of the files - /tmp/rrdcached.sock that changed to root owner because of which gmetad stopped working briefly, but even after changing it back to nobody:nogroup it still complains about the same. All other files have the correct owner. Although, the issue with gmetad was no longer there and we could get the data flushed from rrdcached.

kevallakhani commented 3 years ago

@vvuksan so when it runs the rrdtool xport command in graph.php any idea what user and group it runs it as? is it www-data? or as ganglia user? It mostly seems like this is a permissions issue because of which it cannot access rrdcached I changed the rrdcached command to include FETCH and now I get the rrdtool export output on my command line but when it runs through the ganglia-web request (graph.php) it gives rrdcached: no such file or directory. I think it is some form of user permissions issue on the rrdcached.

kevallakhani commented 3 years ago

@vvuksan Remove the rrdcached_socket from conf.php config and everything works fine are there any tradeoffs to consider in this case? I still have rrdcached flushing data to /var/lib/ganglia/rrds just that the ganglia-web is now not using rrdcached.