Page 1 of 1

UnixODBC db2

Posted: Wed Jun 29, 2016 3:58 am
by martijnmoi
hello,

I am trying to connect my nagios server to an AS/400 DB2 database.

I am using the unixODBC package, But i got stuck when i try to connect to the as/400 which seems to be an driver issue.

I am using this tutorial:
http://wiki.skytech.dk/index.php/Using_ ... _and_AS400

This is the command i am using:

Code: Select all

[root@localhost iSeriesAccess]# isql

**********************************************
* unixODBC - isql                            *
**********************************************
* Syntax                                     *
*                                            *
*      isql DSN [UID [PWD]] [options]        *
*                                            *
* Options                                    *
*                                            *
* -b         batch.(no prompting etc)        *
* -dx        delimit columns with x          *
* -x0xXX     delimit columns with XX, where  *
*            x is in hex, ie 0x09 is tab     *
* -w         wrap results in an HTML table   *
* -c         column names on first row.      *
*            (only used when -d)             *
* -mn        limit column display width to n *
* -v         verbose.                        *
* -lx        set locale to x                 *
* -q         wrap char fields in dquotes     *
* -3         Use ODBC 3 calls                *
* -n         Use new line processing         *
* -e         Use SQLExecDirect not Prepare   *
* -k         Use SQLDriverConnect            *
* --version  version                         *
*                                            *
* Commands                                   *
*                                            *
* help - list tables                         *
* help table - list columns in table         *
* help help - list all help options          *
*                                            *
* Examples                                   *
*                                            *
*      isql WebDB MyID MyPWD -w < My.sql     *
*                                            *
*      Each line in My.sql must contain      *
*      exactly 1 SQL command except for the  *
*      last line which must be blank (unless *
*      -n option specified).                 *
*                                            *
* Please visit;                              *
*                                            *
*      http://www.unixodbc.org               *
*      [email protected]                      *
*      [email protected]              *
**********************************************

[root@localhost iSeriesAccess]# isql AS400 nagios nagios -v
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect


this is my odbcinst.ini:

Code: Select all

[AS400]
Description=IBM i Access for Linux ODBC Driver
Driver=/opt/ibm/iSeriesAccess/lib/libcwbodbc.so
Setup=/opt/ibm/iSeriesAccess/lib/libcwbodbcs.so
Driver64=/opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
Setup64=/opt/ibm/iSeriesAccess/lib64/libcwbodbcs.so
Threading=0
DontDLClose=1
UsageCount=1

[AS400_64]
Description=IBM i Access for Linux 64-bit ODBC Driver
Driver=/opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
Setup=/opt/ibm/iSeriesAccess/lib64/libcwbodbcs.so
Threading=0
DontDLClose=1
UsageCount=1

Is there anyone around with some unixODBC experience?


Kind regards,
Martijn

Re: UnixODBC db2

Posted: Wed Jun 29, 2016 6:06 am
by martijnmoi
update..

i think i've got to the next step, but i walked into the next problem.

i changed these:

Code: Select all

# cat /etc/odbc.ini
[DEFAULT]
Driver = DEFAULT

Code: Select all

# cat /etc/odbcinst.ini
[DEFAULT]
Description = Default Driver
Driver = /opt/ibm/db2/V10.5/lib64/libdb2.so
fileusage=1
dontdlclose=1
And i now got this error:

Code: Select all

# isql DB2 nagios nagios -v
[58031][unixODBC][IBM][CLI Driver] SQL1031N  The database directory cannot be found on the indicated file system.  SQLSTATE=58031

[ISQL]ERROR: Could not SQLConnect
i think this means i've got a connection but it gets stuck after that..



Update2: next i copied this exact tutorial
http://fractio.nl/2007/10/26/setting-up ... emote-db2/

And i've got this same error as above.... I really think i am doing something wrong..

Update 3: I've read something about the ibm licencing...

This is my db2 license check on nagios server side

Code: Select all

# ./db2licm -l
Product name:                     "IBM Data Server Client"
Product identifier:               "db2client"
Version information:              "10.5"



Re: UnixODBC db2

Posted: Wed Jun 29, 2016 9:32 am
by gormank
If it was me, I'd bypass ODBC and use perl. No doubt there's a python interface that does the same thing...

https://www.google.com/#q=perl+dbi+db2
http://www.ibm.com/developerworks/data/ ... reenstein/

Re: UnixODBC db2

Posted: Wed Jun 29, 2016 11:37 am
by tgriep
I am guessing that you are trying to monitor your DB2 database with Nagios XI, if so, you can take a look at our Exchange Site for some plugins to do that and usually they come with instructions to get them working.
Take a look here.
https://exchange.nagios.org/

Re: UnixODBC db2

Posted: Thu Jun 30, 2016 2:15 am
by martijnmoi
gormank wrote:If it was me, I'd bypass ODBC and use perl. No doubt there's a python interface that does the same thing...

https://www.google.com/#q=perl+dbi+db2
http://www.ibm.com/developerworks/data/ ... reenstein/
This way i already tried (with the check_db2_health plugin from labs.consol.de and we do not have the right licenses to monitor this way).

Code: Select all

# ./check_db2_health --port  *** --hostname kpms01.*******.** --username nagios --password nagios --database ********  --mode connection-time
CRITICAL - cannot connect to kpms01.********.**. [IBM][CLI Driver] SQL1598N  An attempt to connect to the database server failed because of a licensing problem.  SQLSTATE=42968
tgriep wrote:I am guessing that you are trying to monitor your DB2 database with Nagios XI, if so, you can take a look at our Exchange Site for some plugins to do that and usually they come with instructions to get them working.
Take a look here.
https://exchange.nagios.org/

I've been on the exchange, I've hopeless been searching google for te past three days.... didn't find the correct solution.

Re: UnixODBC db2

Posted: Thu Jun 30, 2016 10:49 am
by tgriep
I did a quick search of the error message and found this that may help.
http://www-01.ibm.com/support/docview.w ... wg21635635

Is ODBC the only way you can connect to the server?

Re: UnixODBC db2

Posted: Mon Jul 04, 2016 1:50 am
by martijnmoi
tgriep wrote:I did a quick search of the error message and found this that may help.
http://www-01.ibm.com/support/docview.w ... wg21635635

Is ODBC the only way you can connect to the server?
I went over that link like a 1000 times but no results...

Today i clicked around on the IBM site, (which is an very awfull site if you ask me..) but, i found something about the ODBC.ini file, so i changed some lines and it just worked at once. :roll:

For the record: (if someone ever is trying to use the legacy ibm db2 odbc driver)

Check, Check, Double Check your ODBC.ini and ODBCINST.ini files. My problem was definately in the ODBC.ini file.



Topic may be closed.

Re: UnixODBC db2

Posted: Tue Jul 05, 2016 9:01 am
by mcapra
Closing this per your request