Skip to content

Monitor Microsoft SQL Server with Zabbix

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:

  1. Add MSSQL repository
  2. Uninstall any installed ODBC packages
  3. 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.

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:

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Middleware Team

Middleware Team

Posts published under the Middleware Team account are collective contributions by the dbi services middleware and enterprise content management consultants. The practice covers ECM platforms such as OpenText Documentum, Alfresco, and M-Files, as well as application servers and integration technologies including WebLogic, JBoss, Tomcat, and the Elastic Stack, from architecture and deployment to operations under service level agreements.View Author posts

322 posts since February 2013

Most read in Application Server

The Application Server posts our readers open most: the all-time favourites, and what is trending right now.

9 thoughts on “Monitor Microsoft SQL Server with Zabbix”

  1. 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. 

  2. 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.

  3. Olivier Spiesser

    Hello Pavan,
    I guess you have this error message while doing isql test. I am suspecting the Data Source Name (DSN) has not been properly declared in odbc.ini.

  4. 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)).

  5. Olivier Spiesser

    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 with zabbix_sender so that we can trigger on its result (failure or success).
    Regards,
    Olivier

  6. Hi, thank’s for this post, so have you ever tried to connect to MSSQL with Windows authentication and kerberos so on ?

Leave a Comment

Your email address will not be published. Required fields are marked *