netrusov / ZabbixDBA

Zabbix Database Monitoring Service (Oracle, Pg, MySQL, MS SQL, DB2, etc.)
MIT License
97 stars 55 forks source link

Errors on DB2 database though it works OK #88

Closed januschow826 closed 5 years ago

januschow826 commented 5 years ago

Hi Alex, Thanks for providing such a great tool to monitor RDBMS. I test it for oracle and db2,mysql. It's really useful especially for DB2. But i get some error thought it's able to get desired data and it's ok to send data chunk to zabbix-server. I'm not sure if it's a bug where use discovery rule to generate items and gather data automatically. Usually the queries for items in discovery rule will return mutiply lines , but now it will throw errors like as below: [2019/01/30 11:14:04][DEBUG] [ZDBA::DBIx::_fetch:77] fetching data from 'DBI:DB2:fmdb' using 'selectall_arrayref' with options: $VAR1 = { 'keys' => { 'TS' => 'PCT' }, 'options' => { 'Slice' => {} }, 'query' => ' select tbsp_name ts,tbsp_used_size_kb*100/tbsp_total_size_kb pct from SYSIBMADM.TBSP_UTILIZATION where TBSP_TYPE=\'DMS\' ' }; [2019/01/30 11:14:04][ERROR] [ZDBA::DBIx::_fetch:95] failed to execute query on 'DBI:DB2:fmdb': [IBM][CLI Driver][DB2/LINUXX8664] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000

Anyway the log shows that it seems normal as bleow: [2019/01/30 11:14:04][DEBUG] [ZDBA::Sender::send_chunk:110] sending chunk to Zabbix: {"request":"sender data","data":[{"value":"87","key":"ts_usage_pct[FMTBSPACES]","host":"DB2"},{"value":"47","key":"ts_usage_pct[FMIXSPACES]","host":"DB2"},{"value":"12","key":"ts_usage_pct[TBS8K]","host":"DB2"}

Could you please help on it? Thanks a lot!

netrusov commented 5 years ago

hi @januschow826

thanks for your feedback.

I'm sure that it's a bug but not in ZDBA, it's somewhere in DB2 or DBI::DB2 driver, because I only check errstr and print it if present.

if you execute that query against your DB2 database using native CLI do you get some error?

thanks.

januschow826 commented 5 years ago

Hi Alex Sorry for late reply as it's Chinese Spring Festival. It's probably bug in Perl driver, SQL works fine in DB2 CLI. In my opinion, it can't fetch multi rows directly while querying DB2 database via Perl driver with common way, and it need loop to fetch row one by one when resultset has uncertain rows, or bind the values to perl variables and then fetch them. I'm so sorry i have no kownlege on Perl and if we can have some improvement on somewhile to fix this bug or prevent it generating error log all the time although it's INFO debug level([2019/02/11 17:19:07][ERROR] [ZDBA::DBIx::_fetch:95] failed to execute query on 'DBI:DB2:SCDB': [IBM][CLI Driver][DB2/LINUXX8664] SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000)? Thanks a lot !

netrusov commented 5 years ago

hi @januschow826

sorry for the delay.

please try my fix from branch bugfix/disable-bind-variables and see if it helps. I've disabled bind variables bc saw that people are having issues using them (and this feature is totally unnecessary in this tool IMO)

thanks.