ganglia / ganglia-web

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

PHP 8.0 Compatibility #361

Open giddie opened 3 years ago

giddie commented 3 years ago

There seem to be multiple fixes required for compatibility with PHP 8.0.3. It starts with:

2021/04/08 21:58:36 [error] 984#984: *21 FastCGI sent in stderr: "PHP message: PHP Warning:  "continue" targeting switch is equivalent to "break" in /usr/share/webapps/ganglia/functions.php on line 732PHP message: PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function ganglia_api_error_handler(), 4 passed and exactly 5 expected in /usr/share/webapps/ganglia/lib/common_api.php:18
Stack trace:
#0 /usr/share/webapps/ganglia/ganglia.php(353): ganglia_api_error_handler()
#1 /usr/share/webapps/ganglia/get_ganglia.php(11): Gmetad()
#2 /usr/share/webapps/ganglia/index.php(7): include_once('...')
#3 {main}

It seems the fifth argument to set_error_handler() was deprecated a while back, and is now removed in PHP 8. After that:

2021/04/08 21:57:19 [error] 984#984: *19 FastCGI sent in stderr: "PHP message: PHP Warning:  "continue" targeting switch is equivalent to "break" in /usr/share/webapps/ganglia/functions.php on line 732PHP message: PHP Fatal error:  Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/share/webapps/ganglia/ganglia.php:353
Stack trace:
#0 /usr/share/webapps/ganglia/ganglia.php(353): in_array()
#1 /usr/share/webapps/ganglia/get_ganglia.php(11): Gmetad()
#2 /usr/share/webapps/ganglia/index.php(7): include_once('...')
#3 {main}
dirtyharrycallahan commented 3 years ago

This project is dead and there are lots of unpatched vulnerabilities. We ran ganglia for a few years but have since migrated to grafana+prometheus.

giddie commented 3 years ago

I kind of got the impression that it's at least struggling, but I notice there are commits from Jan 2021, so it's not dead dead. But yeah, probably time to consider something else :+1:

outpaddling commented 2 years ago

Munin looks to be pretty comparable to Ganglia and simple to set up. I haven't tried it yet, but will try to remember to report back when I find some time.

zeekus commented 1 year ago

I was able to get ganglia working with php82 on centos7. I made the following changes.

file: /usr/share/ganglia/ganglia.php

Line 353 - 355 commented out this

//if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) { // return TRUE; //}

file: /usr/share/ganglia/ganglia/functions.php line 732 - changed 'continue' to 'break' as described in https://github.com/ganglia/ganglia-web/pull/368

file: /usr/share/ganglia/ganglia/lib/common_api.php line 18: changed funciton to have only the first 4 variables. 18 //function ganglia_api_error_handler ($no, $str, $file, $line, $context) { //old version 19 function ganglia_api_error_handler ($no, $str, $file, $line) {

n8falke commented 1 year ago

Additional: PHP Fatal error: Uncaught Error: Undefined constant "LOCALTIME" in file: cluster_view.php can be fixed by replacing: $cluster[LOCALTIME] with $cluster['LOCALTIME'] in line 617 and 765.

AnkushKapoor-97 commented 1 year ago

Check for the error log file $ vi /var/log/httpd/error_log

$ vi /usr/share/ganglia/dwoo/plugins/builtin/blocks/if.php -> on line 41 change while loop with foreach loop //while (list($k,$v) = each($params)) { foreach ($params as $k => $v) { $ vi /usr/share/ganglia/dwoo/Dwoo/Compiler.php -> On line 3044 change while loop with foreach loop //while (list($k,$v) = each($map)) { foreach ($map as $k => $v) { $ vi /usr/share/ganglia/cluster_view.php -> On line 617 change LOCALTIME to 'LOCALTIME'

sswirski commented 10 months ago

After applying all the above-mentioned changes to the appropriate files in an installation of Ganglia on Debian 12, there is now still one error appearing in /var/log/apache2/error.log:

PHP Fatal error: Uncaught Error: Call to undefined function each() in /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php:2530\nStack trace:\n#0 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1427): Dwoo_Compiler->parseOthers()\n#1 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1674): Dwoo_Compiler->parse()\n#2 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(1365): Dwoo_Compiler->parseFunction()\n#3 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php(805): Dwoo_Compiler->parse()\n#4 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Template/String.php(369): Dwoo_Compiler->compile()\n#5 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Core.php(373): Dwoo_Template_String->getCompiledTemplate()\n#6 /usr/share/ganglia-webfrontend/dwoo/Dwoo/Core.php(299): Dwoo_Core->get()\n#7 /usr/share/ganglia-webfrontend/header.php(449): Dwoo_Core->output()\n#8 /usr/share/ganglia-webfrontend/index.php(38): include_once('...')\n#9 {main}\n thrown in /usr/share/ganglia-webfrontend/dwoo/Dwoo/Compiler.php on line 2530

The line 2530 in /dwoo/Dwoo/Compiler.php reads:

while (list($k,$char) = each($breakChars)) {

so, I assume it needs to be re-written as a foreach as well?

Maybe foreach ($breakChars as $k => $char) { if it follows the same logic as the above? Sorry, I don't know any PHP ;)

EDIT: Yup, that worked!

berlin2123 commented 9 months ago

Thank you all ! its is fixed now in PR #376, which has include some of your fix. it can be easy tested by the rpm files in epel now.

MohammadAliAmir commented 4 months ago

@berlin2123 Is this change already available on epel? what version are we looking for exactly?

berlin2123 commented 4 months ago

yes,verssion >= *-48 , you can check the changelog in epel build system or src

MohammadAliAmir commented 4 months ago

So what I did before was applying all the above mentioned patches to the PHP code with ganglia-web 3.7.5-40 on RHEL9. This still had some issues but I already could see the UI and my data was showing. After updating to 3.7.6-48, It fiddled with my configured apache settings for ganglia, so I set those back correctly but then I again ran into the argument issue where there are 4 expected and 5 given.

So is it possible that the changes are not yet available in that version/release?

berlin2123 commented 4 months ago

you need show the details of that issue.

find isuse >> check >> fix >> finally may send a Pull requests in this repository

MohammadAliAmir commented 4 months ago

Apparently, I was doing something wrong on my end. Had confliciting versions/releases installed with different related packages (gmetad gmond web). When all of these have the same release of -48 this should work. Also had to note that /var/lib/ganglia/rrds should be owned by nobody instead of ganglia (which was in the past so I think?)