[ZBX-18724] Can´t connect MSSQL with ODBC template Created: 2020 Dec 01  Updated: 2020 Dec 04  Resolved: 2020 Dec 04

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Willy RM Assignee: Aleksandrs Pahomovs
Resolution: Won't fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian 10 Zabbix Server 5.2/Client 5.2



 Description   

Steps to reproduce:

  1. Deploy zabbix-agent 5.2
  2. Install ODBC client unixODBC 2.3.7 in Zabbix Server
  3. Configure Host Macros: {$MSSQL.USER} and {$MSSQL.PASSWORD}
  4. Apply template in host, but don´t work

Result:

In Logs Zabbix Server:

707:20201201:133200.618 item "HOST-CLIENT-DB:db.odbc.get[get_status_variables,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
708:20201201:133203.624 item "HOST-CLIENT-DB:mssql.average_wait_time" became not supported: Cannot evaluate expression: "Cannot evaluate function "prev()": not enough data.".
708:20201201:133203.624 item "HOST-CLIENT-DB:mssql.average_latch_wait_time" became not supported: Cannot evaluate expression: "Cannot evaluate function "prev()": not enough data.".
708:20201201:133203.624 item "HOST-CLIENT-DB:mssql.percent_of_adhoc_queries" became not supported: Cannot evaluate expression: "Cannot evaluate function "last()": not enough data.".
708:20201201:133203.624 item "HOST-CLIENT-DB:mssql.percent_recompilations_to_compilations" became not supported: Cannot evaluate expression: "Cannot evaluate function "last()": not enough data.".
709:20201201:133204.625 item "HOST-CLIENT-DB:mssql.scan_to_search" became not supported: Cannot evaluate expression: "Cannot evaluate function "last()": not enough data.".
736:20201201:133500.398 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[availability_groups,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
737:20201201:133501.450 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[dbname,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
736:20201201:133502.451 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[local_db,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
737:20201201:133503.451 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[mirrors,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
736:20201201:133504.504 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[non-local_db,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
737:20201201:133505.556 discovery rule "HOST-CLIENT-DB:db.odbc.discovery[replicas,"\{$MSSQL.DSN}"]" became not supported: Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]

This Host it´s in another WAN, routed with port forward (tcp 10050 and 1433) behind a firewall, with full access to my Zabbix Server. 

The MSSQL Server it´s in a Ubuntu Server, and has a template Linux working.

Please, What can I do to resolver this problem?

Thanks.

 

 



 Comments   
Comment by Willy RM [ 2020 Dec 01 ]

PS. Template name applied MSSQL by ODBC

reference: https://www.zabbix.com/integrations/microsoft_sql

Comment by Aleksandrs Pahomovs [ 2020 Dec 03 ]

Hello,

Could you please provide this command output?

odbcinst -j

Also please try to connect by this one:

isql -v mssqldsn <login> <password>

*mssqldsn you can get from header of /etc/odbc.ini 

What about your configurations files?

for driver /etc/odbcinst.ini and  dsn /etc/odbc.ini 

 

Comment by Willy RM [ 2020 Dec 03 ]

Hi thanks for your help.

See the output of the commands:

admin# odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

admin# isql -v HOST-CLIENT-DB userdb "passworddbuser"

---------------------------------------

Connected!
 
sql-statement
help [tablename]
quit
 

---------------------------------------
SQL>

admin# cat /etc/odbcinst.ini
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.6.so.1.1
UsageCount=1

[ODBC]
Trace = Yes
TraceFile = /var/log/odbc_driver.log

admin# cat /etc/odbc.ini
[HOST-CLIENT-DB]
Driver = ODBC Driver 17 for SQL Server
Server = tcp:hostname.fqdn.fw.com,1433

 

 

Comment by Willy RM [ 2020 Dec 03 ]

Thanks for you help, but I solved this problem here.

I just add the macro {$MSSQL.DSN} in host configuration. With the value: HOST-CLIENT-DB

And worked fine for me.

 

 

Comment by Aleksandrs Pahomovs [ 2020 Dec 04 ]

Please be advised that this section of the tracker is for bug reports only. The case you have submitted can not be qualified as one, so please reach out to [email protected] for commercial support or consultancy services. Alternatively, you can also use our IRC channel or community forum (https://www.zabbix.com/forum) for assistance. With that said, we are closing this ticket. Thank you for understanding. 

Generated at Wed May 20 07:11:33 EEST 2026 using Jira 10.3.18#10030018-sha1:5642e4ad348b6c2a83ebdba689d04763a2393cab.