Zabbix:percona How to use MySQL Monitor plugin

Source: Internet
Author: User
Tags percona egrep

First, configure the Zabbix Agent

1, plug-in installation and configuration


To install the Percona monitoring MySQL package:

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

To view the file path for RPM installation:

[Email protected] ~]# RPM-QL percona-zabbix-templates-1.1.7-1.noarch/var/lib/zabbix/percona/var/lib/zabbix/ Percona/scripts/var/lib/zabbix/percona/scripts/ Get_mysql_stats.php/var/lib/zabbix/percona/templates/var/lib/zabbix/percona/templates/userparameter_percona_ Mysql.conf/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml

where and ss_get_mysql_stats.php are MySQL monitoring scripts for Zabbix agent calls;Userparameter_ Percona_mysql.conf is a configuration file for the Zabbix agent that contains the custom key for MySQL monitoring;zabbix_agent_template_percona_mysql_server_ht_ 2.0.9-sver1.1.7.xml is a Zabbix template file that needs to be imported on the Zabbix Web side.

To view the Zabbix agent's include directory:

[[email protected] ~]# grep ' ^include '/etc/zabbix/zabbix_agentd.confinclude=/etc/zabbix/zabbix_agentd.d/

Copy the configuration file to the Zabbix agent's include directory:


Enter the Percona script directory:


Modify the MySQL connection address in the script:

Vim Get_mysql_stats_wrapper.shhost=localhost

Create the MySQL connection profile ss_get_mysql_stats.php.cnf, write the user name and password:

Vim ss_get_mysql_stats.php.cnf<?php$mysql_user = ' root '; $mysql _pass = ' S3cret ';

    mysql configuration for master-slave monitoring:

vim  find the following line, you can see the MySQL command there is no connection parameters, if your environment to do so no problem, you can not change res= ' Home=~zabbix  mysql -e  ' show slave status\g '  | egrep  ' (slave_io_running| slave_sql_running): '  | awk -F:  ' {print $2} '  | tr  ' \ n '   ', ' #  Add connection parameters after the MySQL command: res= ' home=~zabbix mysql -h localhost -uroot -ps3cret -e  ' Show slave status\g '  | egrep  ' (slave_io_running| slave_sql_running): '  | awk -F:  ' {print $2} '  | tr  ' \ n '   ', ' #  If you are prompted when the script runs "Warning: using a password on the command line interface  can be insecure. ", Workaround res= ' home=~zabbix mysql -h localhost -uroot - ps3cret -e  ' show slave status\g '  2>&1 | egrep  ' (slave_io_ Running| slave_sql_running): '  | awk -F:  ' {print $2} '  | tr  ' \ n '   ', ' 

650) this.width=650; "Src=" 3-wmp_4-s_731625140.png "title=" Slave.png "alt=" Wkiom1mbuxrzo0tqaabcgsy1bak364.png-wh_50 "/>

2. Test scripts

To perform a script test locally:

/var/lib/zabbix/percona/scripts/ Gg/var/lib/zabbix/percona/scripts/get_mysql_stats_ Running-slave

If the test results above are not correct, continue with the debugging below to see the cause of the error:

/usr/bin/php-q/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php--host localhost--items gg

Normal output:

650) this.width=650; "src=" Https:// "title=" Normal test results. png "alt=" Wkiom1mbu8uqb-npaaa8z046dyq917.png "/>

After solving the above problem, use the Zabbix user to execute the script to view the output:

Sudo-u zabbix-h/var/lib/zabbix/percona/scripts/ GG

If you encounter Zabbix user rights issues, workaround:

Rm-f/tmp/localhost-mysql_cacti_stats.txtchown-r Zabbix. /var/lib/zabbix

Normal output:

650) this.width=650; "src=" Https:// "title=" Normal test result 2.png "alt=" Wkiol1mbu82ago3caaawrxip3ho725.png "/>

After all debugging is OK, restart the Zabbix agent:

Service Zabbix-agent Restart

Finally, to Zabbix server-side remote testing:

Zabbix_get-s mysql.key-read-requests

Normal output:

650) this.width=650; "src=" Https:// "title=" Normal test result 3.png "alt=" Wkiol1mbu9fyafksaaaswebxzfy902.png "/>

Second, configure Zabbix Web

1. Zabbix Web-side Import template file

Template file (zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml) in the plug-in installation directory/var/lib/zabbix/percona/ Templates, copy it out and import it into the Zabbix web.

After importing the template name "Percona MySQL Servertemplate", the template is grouped "Percona Templates".

650) this.width=650; "src=" Https:// "title=" Template. png "alt=" Wkiol1mbvcdcgecsaackzhcw6gu819.png "/>

Note: The templates in the official installation package are tested under the zabbix2.0.9 version and are tested for import into zabbix2.0 and version 2.2.

ZABBIX3.0 version environment can not be imported directly, the solution is: Find a zabbix2.2 version of the environment, that is, from the 2.2 version of the export, and then import into the 3.0 version.

2,Zabbix web-side Create host

Create a host that hosts the link template "Percona MySQL Server Templates" to complete the remaining configuration of the host. Wait 5 minutes or so to view MySQL monitoring data.

Attached Percona website Link:


This article is from the "Start Linux blog" blog, make sure to keep this source

Zabbix:percona How to use MySQL Monitor 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: 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.