Icinga / docker-icingaweb2

GNU General Public License v2.0
15 stars 11 forks source link

Documentation Steps for configuring Nagvis with IcingaDB and changes to the core.php function in Nagvis #126

Open adamparker opened 2 months ago

adamparker commented 2 months ago

I had some difficulties with the documentation for installing Nagvis with IcingaDB.

In the step where you add the EmbeddedWeb to the core.php file, it was unable to find the classes for EmbeddedWeb.

icinga2_icingaweb  | [Mon Jul 22 14:25:27.378958 2024] [php7:error] [pid 4846] [client 172.20.0.1:46090] PHP Fatal error:  main(): Failed opening required 'Icinga/Application/EmbeddedWeb.php' (include_path='.:/usr/share/php:../../server/core/classes:../../server/core/classes/objects:../../server/core/ext/php-gettext-1.0.12:../../frontend/nagvis-js/classes/') in /data/usr/local/nagvis/share/server/core/functions/core.php on line 8

I had to add icingaweb2 library to the path to resolve this.

$path = '/usr/share/icingaweb2/library';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

/**
 * Icinga Web 2 integration
 */
use Icinga\Application\EmbeddedWeb;

require_once 'Icinga/Application/EmbeddedWeb.php';
require_once EmbeddedWeb::start('/usr/share/icingaweb2', '/etc/icingaweb2')
    ->getModuleManager()
    ->getModule('nagvis')
    ->getLibDir() . '/nagvis-includes/init.inc.php';

Any suggestions on why this was needed? I am using this inside a docker environment if that helps.

yhabteab commented 1 week ago

Hi @adamparker, thans for reporting!

Any suggestions on why this was needed? I am using this inside a docker environment if that helps.

Actually, when installing Icinga Web 2 from packages the icingaweb2/library/Icinga is installed into the /usr/share/php/Icinga directory and since /usr/share/php is already set as an include path (include_path='.:/usr/share/php:), this works without any issues. However, our Icinga Web 2 Docker images do not seem to follow this package installation path, which leads to this kind of include path errors for you, so you may want to open an issue there so that it automatically creates a symlink or something in that include path without you having to set the this /usr/share/icingaweb2/library manually.