centreon / centreon-nagvis

A module to integrate Nagvis into Centreon in order to have simple graphical views
10 stars 10 forks source link

Incompatible with recent Nagvis #6

Open sathieu opened 8 years ago

sathieu commented 8 years ago

With Nagvis 1.9b2, I have:

mod_fcgid: stderr: PHP Fatal error:  Cannot redeclare debug() (previously declared in /usr/share/centreon/www/modules/centreon-nagvis/index.php:158) in /usr/local/share/nagvis/share/server/core/functions/debug.php on line 43, 
mod_fcgid: stderr: PHP Fatal error:  Cannot redeclare get_error() (previously declared in /usr/share/centreon/www/include/common/common-Func.php:1751) in /usr/local/share/nagvis/share/server/core/functions/html.php on line 67, 
mod_fcgid: stderr: PHP Fatal error:  Cannot redeclare microtime_float() (previously declared in /usr/share/centreon/www/header.php:40) in /usr/local/share/nagvis/share/server/core/functions/debug.php on line 70, 

and maybe more...

mathieuchateau commented 8 years ago

me too with stable nagvis 1.8.5

mathieuchateau commented 8 years ago

I did a workaround on my side, waiting for official fix. I am afraid I am not understanding code good enough to know if my changes are correct:

Inside nagvis, line 30 nagvis/share/server/core/functions/debug.php, comment out:

//define('DEBUGSTART',microtime_float());

inside nagvis, like 76, nagvis/share/server/core/functions/html.php change to only declare if not already

if(function_exists('get_error')){
    // my_function is defined
}
else
{
function get_error($key) {
    global $form_errors;
    return isset($form_errors[$key]) ? $form_errors[$key] : array();
}
}

inside centreon, at end of centreon/www/modules/centreon-nagvis/index.php, comment out:

/*
function debug($msg) {
    $fh = fopen(DEBUGFILE, 'a');
    fwrite($fh, utf8_encode(microtime_float().' '.$msg."\n"));
    fclose($fh);
}
*/
cemir commented 8 years ago

Hi,

same errors for me with Centreon 2.6.6 and NagVis 1.8.5

in addition of mathieuchateau's modifications, I had to comment in file nagvis/share/server/core/functions/debug.php

     67 /*
     68 function microtime_float() {
     69         list($usec, $sec) = explode(' ', microtime());
     70         return ((float)$usec + (float)$sec);
     71 }
     72 */
RefreshMyMind commented 7 years ago

In the root folder of nagvis, run the following: sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/ext/php-gettext-1.0.9/gettext.inc sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/classes/CoreAuthorisationHandler.php sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/classes/CoreSQLiteHandler.php sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/classes/GlobalLanguage.php sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/classes/CoreAuthHandler.php sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/classes/CoreMySQLHandler.php sed -i -e "s/debug(/debug_nagvis(/g" ./share/server/core/functions/debug.php sed -i -e "s/microtime_float(/microtime_float_nagis(/g" ./share/server/core/functions/debug.php

kozfelipe commented 7 years ago

I got the same issue. Thanks for the workaround. Still waiting on an official fix