In this blog post, we will quickly see what is required to monitor a Microsoft SQL Server with Zabbix.
Agent Setup
Agent setup is not required by MSSQL by ODBC template; thus this step can be skipped.
Setup Monitoring Account
The best practice is to create an account in the database dedicated to monitoring which will have limited permissions (view, select). Setup chapter of MS SQL integration on Zabbix web site explains it well.
In our example, this user will be named zbx_monitor.
ODBC Driver Linux
Zabbix server will trigger SQL queries directly against MS SQL Server. To achieve this, it requires ODBC to be set up locally.
Questions about your own setup? A dbi services consultant can look at your case.
Talk to an expert (opens in a new tab)You can refer to Microsoft web site (link here) which provides all the steps to install ODBC driver depending on your linux flavor. Roughly, installation is composed of following steps:
- Add MSSQL repository
- Uninstall any installed ODBC packages
- Install Microsoft driver
Setup Data Source Name (DSN)
Before being able to use driver, we must declare it in /etc/odbcinst.ini:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1
UsageCount=1
Next, we can declare DSN in /etc/odbc.ini:
[mssql-mfiles]
Description = MS SQL M-Files Database
Driver = ODBC Driver 17 for SQL Server
Server = <IP>
Port = 1433
User = zbx_monitor
Password = <password>
Database = msdb
The name between square bracket is the DSN that we will use later in the Zabbix configuration. Note that the ODBC driver does not use password from that file.
Finally, we can test our ODBC setup with the command:
isql -v mssql-mfiles zbx_monitor <password>
If all worked as expected, you should see this output and get a SQL prompt:
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| echo [string] |
| quit |
| |
+---------------------------------------+
SQL>
To active ODBC poller on Zabbix, we must uncomment line in /etc/zabbix/zabbix_server.conf:
StartODBCPollers=5
Followed by a zabbix_server service restart.
Link MSSQL by ODBC Template
Next step is in the Zabbix UI. Link MSSQL by ODBC template to the host and set the following macros:
- {$MSSQL.USER}
- {$MSSQL.PASSWORD}
- {$MSSQL.DSN} as defined in
/etc/odbc.ini(ie. mssql-mfiles) - {$MSSQL.INSTANCE} if different from
SQLServer
As an example, it might look like this:

After few seconds, you should see discovered databases and new items:

As well as pre-built dashboards:

Glad to learn you found a way. Thanks for the feedback.
Hi Oliver,
Working after updating the ODBC driver from 17 to 18
Yes, I tried with zabbix user, and I am getting the same error. When I try to grant read access to files “odbc.ini and odbcinst.ini” for zabbix user, the zabbix server is not running pops up in zabbix consol.
Did you try as zabbix user on the zabbix server?
Hi Olivier,
The isql is working with root user perfectly and i am able to connect to the mssql server, this error i am getting in zabbix console when i execute the item.
Hello Pavan,
I guess you have this error message while doing
isqltest. I am suspecting the Data Source Name (DSN) has not been properly declared in odbc.ini.Cannot connect to ODBC DSN: [SQL_ERROR]:[IM002][0][[unixODBC][Driver Manager]Data source name not found and no default driver specified]
i am getting this error in zabbix console…my zabbix server running under default “zabbix” user (Linux (ubuntu 22.04)).
Hi Eric,
I have created a bash script, scheduled via cron under zabbix user, to update the ticket with
kinit. The same script update a zabbix items withzabbix_senderso that we can trigger on its result (failure or success).Regards,
Olivier
Hi, thank’s for this post, so have you ever tried to connect to MSSQL with Windows authentication and kerberos so on ?