This is an old revision of the document!
ODBC monitoring corresponds to the Database monitor item type in the Zabbix frontend.
ODBC is a C programming language middle-ware API for accessing database management systems (DBMS). The ODBC concept was developed by Microsoft and later ported to other platforms.
Zabbix may query any database, which is supported by ODBC. To do that, Zabbix does not directly connect to the databases, but uses the ODBC interface and drivers set up in ODBC. This function allows for more efficient monitoring of different databases for multiple purposes - for example, checking specific database queues, usage statistics and so on. Zabbix supports unixODBC and iODBC, which are the two most commonly used open source ODBC API implementations.
The suggested way of installing unixODBC is to use the Linux operating system default package repositories. In the most popular Linux distributions unixODBC is included in the package repository by default. If it's not available, it can be obtained at the unixODBC homepage: http://www.unixodbc.org/download.html.
unixODBC installation using the yum package manager:
shell> yum -y install unixODBC unixODBC-devel
A unixODBC database driver should be installed for the database, which will be monitored. unixODBC has a list of supported databases and drivers: http://www.unixodbc.org/drivers.html. In some Linux distributions database drivers are included in package repositories.
For example, a MySQL database driver can be installed using the yum package manager:
shell> yum install mysql-connector-odbc
ODBC configuration is done by editing the odbcinst.ini and odbc.ini files. To verify the configuration file location, type:
shell> odbcinst -j
odbcinst.ini is used to list the installed ODBC database drivers:
[mysql] Description = ODBC for MySQL Driver = /usr/lib/libmyodbc5.so
|mysql||Database driver name.|
|Description||Database driver description.|
|Driver||Database driver library location.|
odbc.ini is used to define data sources:
[test] Description = MySQL test database Driver = mysql Server = 127.0.0.1 User = root Password = Port = 3306 Database = zabbix
|test||Data source name (DSN).|
|Description||Data source description.|
|Driver||Database driver name - as specified in odbcinst.ini|
|Server||Database server IP/DNS.|
|User||Database user for connection.|
|Password||Database user password.|
|Port||Database connection port.|
To verify if ODBC connection is working successfully, a connection to database should be tested. That can be done with the isql utility (included in the unixODBC package):
shell> isql test +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
To enable ODBC support, Zabbix should be compiled with one of following flags:
--with-iodbc[=ARG] use odbc driver against iODBC package [default=no], --with-unixodbc[=ARG] use odbc driver against unixODBC package
Configure a database monitoring item:
Specifically for database monitoring items you must enter:
|Type||Select Database monitor here.|
The unique description will serve to identify the item in triggers etc.
|Additional parameters||DSN - data source name (as specified in odbc.ini)
user - database user name (optional if user is specified in odbc.ini)
password - database user password (optional if password is specified in odbc.ini)
sql - SQL query
|Type of information||It is important to know what type of information will be returned by the query, so that it is selected correctly here. With an incorrect type of information the item will turn unsupported.|