Zabbix 3.2.6 monitoring MySQL via ODBC

Source: Internet
Author: User
Tags odbc connection

I. Overview

ODBC monitoring is basically consistent with the Zabbix front-end configuration database monitoring entry type.

ODBC is a C language used to connect the database management system of a middleware, initially Microsoft company developed, and later developed to the major platforms.

With ODBC support, Zabbix can query many kinds of databases, because Zabbix not directly to the database, but through the ODBC interface and driver, so it can be more efficient to monitor the different databases.

Second, installation configuration

1. Compiling Zabbix server

To support ODBC functionality, you need to add--with-unixodbc when compiling, to resolve dependencies need to install the following packages,

Yum-y Install UnixODBC Unixodbc-devel

2, install UNIXODBC Drive

Driver is used for ODBC connection database, he can support a variety of drivers, in most of the Linux distribution in the warehouse, there are these drivers, we installed a MySQL driver, used to monitor the MySQL database.

Yum Install Mysql-connector-odbc

3, Configuration Unixodbc

ODBC configuration is mainly by modifying the Odbcinst.ini and Odbc.ini two files, you can use the following command to specify the location of the configuration file.

# Odbcinst-junixodbc 2.2.14DRIVERS .....:/etc/odbcinst.inisystem data SOURCES:/etc/odbc.inifile data SOURCES. :/etc/odbcdatasourcesuser DATA SOURCES.:/root/.odbc.inisqlulen Size ...: 8SQLLEN size ......: 8SQLSETPOSIROW Size.: 8

Odbcinst.ini is mainly configured to install the ODBC database driver, each field meaning I no longer introduce.

[MySQL]        Description = ODBC for mysqldriver =/usr/lib/libmyodbc5.sosetup =/usr/lib/libodbcmys.sodriver64 =/USR/LIB64/LIBMYODBC5.SOSETUP64 =/usr/lib64/libodbcmys.sofileusage = 1

Odbc.ini is primarily a configuration data source.

[Test]        Description = MySQL Test databasedriver = MySQLServer = 127.0.0.1User = Zabbixpassword = Zabbixport = 3306Database = Zabbix

We can determine whether we can successfully connect to the database by installing a command isql when installing UNIXODBC.

# isql test+---------------------------------------+| connected!                              | |                                          | |  sql-statement                          | |  help [tablename]                       | |  quit                                    | |                                          |+---------------------------------------+sql>

4. Configuring the Zabbix front-end Web

First, create a monitoring entry.

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9C/17/wKiom1lsL5PxJsynAABL0OCWHHY753.jpg "title=" Qq20170717113010.jpg "alt=" Wkiom1lsl5pxjsynaabl0ocwhhy753.jpg "/>

These entries are required and are explained in the following detail:

Type Here we choose Database Monitor
Key

Select Db.odbc.select[unique_description,data_source_name]

Unique_description will be used for the entry in the trigger

Data_source_name fill in the test in Odbc.ini

User Name Enter the user name in the Odbc.ini
Password Enter the password in the Odbc.ini
SQL Query Enter SQL query statement
Type of information What is the return value of our previous query, and the correct selection will be supported

5. Precautions

    • Query statement execution time cannot exceed the configured timeout time

    • The query only allows a value to be returned.

    • If a query statement returns more than one column, it reads only the first column

    • If the query statement returns more than one row, it reads the first

    • The SQL statement must be the start of a select and only a query statement.

    • SQL statements cannot contain newline characters

6. Error messages

Starting with Zabbix 2.08, ODBC provides the following detailed error messages:

Cannot execute odbc query:[sql_error]:[42601][7][error: syntax error at or  near  ";";  error while executing the query]|-------------------------  ---------    -----  |  -------------------------------------------------------------- ----- |            |                   |          |     '- native error code              '- error message.                        '-  Record separator            |                   |           '-sqlstate              '- zabbix message   '- odbc return code

The maximum error message cannot exceed 128 bytes, so the error message is truncated too long.

Third, verification

Since we did not create an image, we can view the entries we created from the latest database.

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9C/17/wKioL1lsMzaCmbclAAHalFPtNAM105.jpg "title=" Qq20170717114533.jpg "alt=" Wkiol1lsmzacmbclaahalfptnam105.jpg "/>

You can write more complex SQL query statements and make triggers to monitor the database in more detail.




650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9C/18/wKiom1lsM3jSL2SyAACmb4CVfN4162.jpg "title=" Qrcode_for_gh_891f5ff6ec4e_258.jpg "alt=" Wkiom1lsm3jsl2syaacmb4cvfn4162.jpg "/>

This article is from the "Operation and maintenance bit record" blog, please make sure to keep this source http://wzlinux.blog.51cto.com/8021085/1948160

Zabbix 3.2.6 monitoring MySQL via ODBC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.