centreon / centreon-clapi

Centreon CLAPI Module
14 stars 14 forks source link

Uncaught PDOException - Invalid datetime format #373

Closed RJSOG closed 3 years ago

RJSOG commented 4 years ago

Centreon Version: 20.04.0 Command: centreon -u admin -p xyz -i clapi_export.txt

Hi i want to change my central host so i used clapi , the both server are in centreon 20.04.0 but when i am trying to import the configuration i am getting this error:

"PHP Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column centreon.on_demand_macro_service.is_password at row 1 in /usr/share/centreon/www/class/centreonDB.class.php:274 Stack trace:

0 /usr/share/centreon/lib/Centreon/Object/Object.php(117): CentreonDB->query('INSERT INTO on_...', Array)

1 /usr/share/centreon/www/class/centreon-clapi/centreonService.class.php(722): Centreon_Object->insert(Array)

2 /usr/share/centreon/www/class/centreon-clapi/centreonAPI.class.php(806): CentreonClapi\CentreonService->setmacro('VCENTER-HOST-12...')

3 /usr/share/centreon/www/class/centreon-clapi/centreonAPI.class.php(769): CentreonClapi\CentreonAPI->launchActionForImport()

4 /usr/share/centreon/bin/centreon(196): CentreonClapi\CentreonAPI->import('centreon-clapi-...')

5 {main}"

Does anyone have a way to fix this ?

MegaS0ra commented 3 years ago

Got this problem today, and managed to solve it.

With recent MariaDB versions, strict mode in enabled by default, and it seems Centreon does not support it yet. You can check it is enabled by connecting to MySQL cli, and running this command : show variables LIKE "sql_mode";

Which should output :

+---------------+-------------------------------------------------------------------------------------------+
| Variable_name | Value                                                                                     |
+---------------+-------------------------------------------------------------------------------------------+
| sql_mode      | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)

To fix it, edit your /etc/my.cnf.d/server.cnf file and uncomment the following line : #sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' then restart MariaDB.

The clapi import should now work.

RJSOG commented 3 years ago

Thanks !