Dear community,
since our director workshop we know, that’s also easy to import data directly from a SQL-database instead of csv/txt files. We have our own CMDB where we manage our infrastructure. The database system is IBM DB2.
Situation now:
Now is we get the data with a perl script and the IBM DB2-ODBC driver from our CMDB. The Installation of the driver was at the beginning not easy, but after some setbacks I could handle it (for people who are interested in: With this documentaiton it was very easy to install the driver for the way I needed it with perl: https://www.froebe.net/blog/2017/10/06/howto-ibm-db2-odbc-and-linux-nix-configuration/).
We created a cron job which runs the script to produce the csv file for the import into the director. Everything works fine. But not every of my colleagues can maintain this, if something changes.
Future:
I saw in the source code of Icingaweb2 that a data source could also be IBM DB2, if the PHP extensions are installed and loaded. So my idea now is don’t use the intermediate step with the script and use the director feature to get the data directly from the database. Now I’m testing this …
First of all with the ODBC-DB2-driver this doesn’t work. You’ll need the “big” Driver packet from IBM. Here are, besides the driver, some extensions for programming langues included (also the Java, Python, Perl, PHP etc. extensions). So I got this from our database-admin.
For interested people: This documentation is very good for the installation https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.swg.im.dbclient.php.doc/doc/t0011926.html.
After the experience with the odbc-driver and the documentation the installation was not so difficult. Only a few tricks were needed, maybe because of our configuration. You can use the PHP extensions from the driver packet or get the latest Version from PECL (https://pecl.php.net/package/PDO_IBM and https://pecl.php.net/package/PDO_IBM). I used the latest version from PECL, because IBM wrote in the docs it’s recommended.
After Installation, PHP loaded the extension successfully and we created a new database ressource at the configuration menue in icingaweb2. Now there is the possibility to choose a new database type “IBM (DB2)”.
After input the connection data to our DB2 icingaweb2 can connect to it.

So far, everything is successful!
Problem now:
Now I want to insert the first SQL Statement in the director to get the data.
If I want to save this, I got following error message:

And I don’t know where it comes from to debug this. I also don’t found the message in the source code of icingaweb2. Maybe somewhere are some further options needed.
Because the connections with my perl script works perfect for us. Here I use the dbi package. And here I had to use some options for connect-command (LongTruncOk => 1, LongReadLen=> 20000). I guess something like this is missing for the connection with PHP.
Maybe someone has ideas or can give me some hints.
Thank you
Stefan