Zabbix monitoring MySQL database using Percona Zabbix mysql-plugin

Source: Internet
Author: User
Tags install php percona egrep

Since the Zabbix comes with a MySQL monitoring template that monitors things less, you should use Percona Zabbix mysql-plugin to monitor MySQL as required by your company's DBA.

Percona Zabbix Mysql-plugin is a tool released by Percona that uses Zabbix to monitor MySQL database, which is much more powerful than Zabbix's own monitor template, after all, Percona is an important branch of MySQL, Professional database, so the data collected is more comprehensive.

Well, the introduction of the background is here, the following start to get to the point, the deployment of MySQL monitoring.

First, need to install and install PHP and Php-mysql, because the use of PHP script, so in this machine need to install PHP, as for the installation of PHP is not the focus of this article, in my previous blog has written how to install PHP, here is not repeated discussion.

Then, you need to go to Percona official website to download the latest version of Percona Zabbix Mysql-plugin, starting from the 1.1 version of the support Zabbix, including Cacti,nagios also have an interface to provide, here we download Percona Zabbix Mysql-plugin, link in this: https://www.percona.com/downloads/percona-monitoring-plugins/1.1.5/ percona-zabbix-templates-1.1.5-1.noarch.rpm

Use after download

RPM-IVH percona-zabbix-templates-1.1.5-1.noarch.rpm

installation, after installation will produce two directories, each directory has two files, the detailed results are as follows:

[Email protected] ~]# ls/var/lib/zabbix/percona/scripts templates[[email protected] ~]# ls/var/lib/zabbix/percona/ scripts/get_mysql_stats_wrapper.sh Ss_get_mysql_stats.php[[email protected] ~]# ls/var/lib/zabbix/percona/ Templates/userparameter_percona_mysql.conf Zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.5.xml

First, we need to download the template file zabbix_agent_template_percona_mysql_server_ht_2.0.9- Sver1.1.5.xml then import this template file into the Zabbixweb-side template, and then put the configuration text userparameter_percona_mysql.conf into the Zabbix profile directory, my directory is/usr/ local/zabbix-2.4.4/etc/zabbix_agentd.conf.d/

Then modify the zabbix_agentd.conf configuration file, add the directory where the configuration file is located, that is, add the following line of statements:

Include=/usr/local/zabbix-2.4.4/etc/zabbix_agentd.conf.d/*.conf

Then modify the script, first modify the Sh script, that is, get_mysql_stats_wrapper.sh this script, the following statement to modify:

res= ' Home=~zabbix mysql-e ' SHOW SLAVE status\g ' | Egrep ' (slave_io_running| slave_sql_running): ' | Awk-f: ' {print $} ' | Tr ' \ n ', ' '

Modified to:

res= '/usr/local/mysql/bin/mysql-uroot-e ' SHOW SLAVE status\g ' | Egrep ' (slave_io_running| slave_sql_running): ' | Awk-f: ' {print $} ' | Tr ' \ n ', ' '

MySQL does not have a root password here, you can write the corresponding account password for MySQL here.

Also need to note, in this script need to call PHP to implement monitoring, so need to modify the PHP path, my php path is/usr/local/php/bin/php, so I changed the script in the command to the following:

cmd= "/usr/local/php/bin/php-q $DIR/ss_get_mysql_stats.php--host $HOST--items gg"

Then save the script and modify the permission to 755

Then modify the php script file, modify the user name and password as follows:

$mysql _user = ' root '; $mysql _pass = '; $mysql _port = 3306;

Because my mysqlroot password is empty, so my password is not entered here, you can change into the corresponding account password.

After the modification to save the configuration and set the permissions to 755, and then restart Zabbix_agentd, on the zabbix_server side to add just the template we imported, we can realize the monitoring of MySQL, the following is monitored:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/3B/wKiom1X37L6iVNK1AAIfR9Q2rdo459.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1x37l6ivnk1aaifr9q2rdo459.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/38/wKioL1X37vSDlTgRAAKpRn6oNqc505.jpg "style=" float: none; "title=" 2.png "alt=" Wkiol1x37vsdltgraakprn6onqc505.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/3B/wKiom1X37MCC5th_AAGMmhgEvko208.jpg "style=" float: none; "title=" 3.png "alt=" Wkiom1x37mcc5th_aagmmhgevko208.jpg "/>

But it seems that this template for a single database, although sufficient detail, the monitoring of the database cluster is not enough to force, need to be modified on the basis of its monitoring script, so that it can monitor the status of the database cluster information that would be better, of course, I only do a single database monitoring, cluster because there is no actual deployment, There is no demonstration here, children's shoes interested in this area can read the script source code, modify the script to achieve detailed monitoring of the MySQL cluster. This tutorial is written here, thank you for your time, sprinkle flowers


This article is from the "Lemon" blog, be sure to keep this source http://xianglinhu.blog.51cto.com/5787032/1695045

Zabbix monitoring MySQL database using Percona Zabbix mysql-plugin

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.