glinuz / db2_exporter

Prometheus IBM DB2 exporter
MIT License
17 stars 7 forks source link

Error: panic: SQLGetDiagRec failed: ret=-2 #3

Closed tsoft-globalproject closed 3 years ago

tsoft-globalproject commented 3 years ago

Hello,

I am trying to run this monitoring as per the suggested steps, but when I run this command: ./main -log.level debug -dsn "DATABASE=Users;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP;UID=db2inst1;PWD=Test012123; " I get this error: panic: SQLGetDiagRec failed: ret = -2

goroutine 1 [running]: github.com/ibmdb/go_ibm_db.NewError(0x7efc3c, 0xe, 0x75be00, 0xce1100, 0xc000048eb8, 0x4dc5e6) /usr/local/go/src/github.com/ibmdb/go_ibm_db/error.go:58 + 0x50a github.com/ibmdb/go_ibm_db.initDriver(0x0, 0x0) /usr/local/go/src/github.com/ibmdb/go_ibm_db/driver.go:29 + 0x22e github.com/ibmdb/go_ibm_db.init.0 () /usr/local/go/src/github.com/ibmdb/go_ibm_db/driver.go:53 + 0x22

Please could you help me.

I am running a Java client to test the connection and it works perfect with these parameters: String DB2Driver = "com.ibm.db2.jcc.DB2Driver"; String DB2ConnectionURL_users = "jdbc:db2://localhost:50000/Usuarios"; String DB2UserName = "db2inst1"; String DB2Password = "Test012123";

Thank you.

glinuz commented 3 years ago

Do you build from source,or my release binary package? It is like a ODBC dirver problem.

tsoft-globalproject commented 3 years ago

Hello, thanks for answering,

Attached is the complete sequence of the executed commands. It is built from sources:

[root@serv-db2 db2_exporter-master]# ll total 328 -rw-r--r-- 1 root root 17095 Nov 5 2019 db2-alert.png -rw-r--r-- 1 root root 537 Nov 5 2019 db2exporter-rules.yml -rw-r--r-- 1 root root 32488 Nov 5 2019 db2exporter_zabbix_templates.xml -rw-r--r-- 1 root root 7933 Nov 5 2019 db2script.txt -rw-r--r-- 1 root root 1743 Nov 5 2019 default-metrics.toml drwxrwxrwx 9 root root 117 Nov 5 2019 github.com drwxrwxrwx 3 root root 15 Nov 5 2019 golang.org -rw-r--r-- 1 root root 221579 Nov 5 2019 ibmdb2.png -rw-r--r-- 1 root root 1099 Nov 5 2019 LICENSE -rw-r--r-- 1 root root 11409 Dec 26 18:09 main.go -rw-r--r-- 1 root root 857 Nov 5 2019 Makefile -rw-r--r-- 1 root root 350 Nov 5 2019 metric-dual-example.toml -rw-r--r-- 1 root root 521 Nov 5 2019 multi-metric-dual-example-labels.toml -rw-r--r-- 1 root root 5748 Nov 5 2019 README.md drwxr-xr-x 2 root root 6 Dec 25 12:32 vendor -rw-r--r-- 1 root root 2098 Nov 5 2019 vendor.json [root@serv-db2 db2_exporter-master]# export IBM_DB_DIR=/opt/ibm/db2/V11.5 [root@serv-db2 db2_exporter-master]# export CGO_LDFLAGS=-L$IBM_DB_DIR/lib64 [root@serv-db2 db2_exporter-master]# export CGO_CFLAGS=-I$IBM_DB_DIR/include [root@serv-db2 db2_exporter-master]# go build main.go [root@serv-db2 db2_exporter-master]# ll total 9652 -rw-r--r-- 1 root root 17095 Nov 5 2019 db2-alert.png -rw-r--r-- 1 root root 537 Nov 5 2019 db2exporter-rules.yml -rw-r--r-- 1 root root 32488 Nov 5 2019 db2exporter_zabbix_templates.xml -rw-r--r-- 1 root root 7933 Nov 5 2019 db2script.txt -rw-r--r-- 1 root root 1743 Nov 5 2019 default-metrics.toml drwxrwxrwx 9 root root 117 Nov 5 2019 github.com drwxrwxrwx 3 root root 15 Nov 5 2019 golang.org -rw-r--r-- 1 root root 221579 Nov 5 2019 ibmdb2.png -rw-r--r-- 1 root root 1099 Nov 5 2019 LICENSE -rwxr-xr-x 1 root root 9546176 Dec 28 09:04 main -rw-r--r-- 1 root root 11409 Dec 26 18:09 main.go -rw-r--r-- 1 root root 857 Nov 5 2019 Makefile -rw-r--r-- 1 root root 350 Nov 5 2019 metric-dual-example.toml -rw-r--r-- 1 root root 521 Nov 5 2019 multi-metric-dual-example-labels.toml -rw-r--r-- 1 root root 5748 Nov 5 2019 README.md drwxr-xr-x 2 root root 6 Dec 25 12:32 vendor -rw-r--r-- 1 root root 2098 Nov 5 2019 vendor.json [root@serv-db2 db2_exporter-master]# [root@serv-db2 db2_exporter-master]# export DB2_HOME=/opt/ibm/db2/V11.5 [root@serv-db2 db2_exporter-master]# export LD_LIBRARY_PATH=$DB2_HOME/lib64:$LD_LIBRARY_PATH [root@serv-db2 db2_exporter-master]# ./main -log.level debug -dsn "DATABASE=Usuarios;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP;UID=db2inst1;PWD=Test012123;" panic: SQLGetDiagRec failed: ret=-2

goroutine 1 [running]: github.com/ibmdb/go_ibm_db.NewError(0x7efc3c, 0xe, 0x75be00, 0xce1100, 0xc000048eb8, 0x4dc5e6) /usr/local/go/src/github.com/ibmdb/go_ibm_db/error.go:58 +0x50a github.com/ibmdb/go_ibm_db.initDriver(0x0, 0x0) /usr/local/go/src/github.com/ibmdb/go_ibm_db/driver.go:29 +0x22e github.com/ibmdb/go_ibm_db.init.0() /usr/local/go/src/github.com/ibmdb/go_ibm_db/driver.go:53 +0x22 [root@serv-db2 db2_exporter-master]#

Please your comments.

glinuz commented 3 years ago

1.My DB2 server version V10.5.So DB2 v11,Mybe.. 2.IBM_DB_DIR DB2_HOME must be DB2 Instance path. As /home/db2inst1/sqllib (db2icrt) 3.Or repair DB2 instance privillage /opt/ibm/db2/V10.5/instance/db2iupdt db2inst1

tsoft-globalproject commented 3 years ago

Perfect, it works, thanks

Another query, in the connection parameter it is passed the name of the database, but if I have several databases, how do you have to do it to monitor several databases? And if it is possible to carry out this monitoring from a remote client computer, installing only the DB2 client with its drivers on the client computer, will it be possible?

thanks

glinuz commented 3 years ago

It is design to run with DB2 server,Add auto registry to consul + promethues. Mybe you write shell script.