Problem after x509 Module install

Good Morning Community.

I ran into a bit of an issue after installing the x509 module on one of our satellites.

  • debian 9.9
  • Icinga 2.10.4
  • Icingaweb 2.6.3
  • ipl 0.3.0
  • reactbundle 0.6.0
  • x509 1.0.0
  • php 7.0
  • php-gmp 7.0
  • OpenSSL 1.1.0
  • MariaDB 10.1.38

Installed according to the documentation on Github forst of all i ran into a fault when trying to import the certificates via icingacli:

icingacli x509 import --file /etc/ssl/certs/ca-certificates.crt 
ERROR: PDOException in /usr/share/icingaweb2/modules/ipl/vendor/ipl/sql/src/Connection.php:146 with message: could not find driver

Looking into said file line 146 is th last line of this block:

   protected function createPdoAdapter()
{
    $adapter = $this->getAdapter();

    $config = $this->getConfig();

    return new PDO(
        $adapter->getDsn($config),
        $config->username,
        $config->password,
        $adapter->getOptions($config)
    );
}

Digging deeper (since the script running my LED status lights was giving back a crit) running a manual

icingacli monitoring list hosts --host_problem --host_unhandled --format=csv

gave me a php error:

PHP Fatal error:  Uncaught Error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in /usr/share/php/Icinga/Data/Db/DbConnection.php:198
Stack trace:
#0 /usr/share/php/Icinga/Data/Db/DbConnection.php(78): Icinga\Data\Db\DbConnection->connect()
#1 /usr/share/php/Icinga/Data/ResourceFactory.php(103): Icinga\Data\Db\DbConnection- >__construct(Object(Icinga\Data\ConfigObject))
#2 /usr/share/php/Icinga/Data/ResourceFactory.php(136): Icinga\Data\ResourceFactory::createResource(Object(Icinga\Data\ConfigObject))
#3 /usr/share/icingaweb2/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php(225): Icinga\Data\ResourceFactory::create('icinga_ido')
#4 /usr/share/icingaweb2/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php(300): Icinga\Module\Monitoring\Backend\MonitoringBackend->getResource()
#5 /usr/share/icingaweb2/modules/monitoring/library/Monitoring/DataView/DataView.php(53): Icinga\Module\Monitoring\Backend\MonitoringBackend->query('HostStatus', Array)
#6 /usr/share/icingaweb2/modules/monitoring/libr in /usr/share/php/Icinga/Data/Db/DbConnection.php on line 198

So something is messed up around line 198 in the DbConnection.php (probably related to the top mentioned file as well):

$driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] =
   'SET SESSION SQL_MODE=\'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,'
        . 'ANSI_QUOTES,PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION\'';

Running a “icinga2 daemon -C” gives nothing pack that would count towards the problem (config is ok, just a few unused apply rules).

The question now is where did i mess up?

Hi,

both errors lead to the real problem - the PHP PDO MySQL package is missing. While the IPL error is correct about the driver, the stacktrace somehow tells you that a constant which is injected into PHP’s scope, is missing. This originates from the MySQL PHP driver package.

I don’t recall exactly how the package name is called on Debian, but php7.0-mysql or similar.

Cheers,
Michael

Well the second coffee definetly helped finding that a hint towards the PDO Module but on windows and like 30sec. later your answer came in.

Seems to be working now (at least the fault is gone), so back to configuration.

Thanks a bunch!

1 Like

Ah, the second coffee. BRB. Then I’ll hunt Windows crashes again for 2.11 :kissing_heart:

On Debian 10.10 I solved with:

apt-get install php7.3-gmp