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

: https://www.percona.com/downloads/percona-monitoring-plugins/

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_wrapper.sh/var/lib/zabbix/percona/scripts/ss_ 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 get_mysql_stats_wrapper.sh 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:

cp/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf/etc/zabbix/zabbix_agentd.d/

Enter the Percona script directory:

Cd/var/lib/zabbix/percona/scripts

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 get_mysql_stats_wrapper.sh#  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=" https://s2.51cto.com/wyfs02/M01/00/A8/wKiom1mbuxrzo0TQAABcGSy1bak364.png-wh_500x0-wm_ 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/get_mysql_stats_wrapper.sh Gg/var/lib/zabbix/percona/scripts/get_mysql_stats_ Wrapper.sh 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://s4.51cto.com/wyfs02/M00/00/A8/wKiom1mbu8uQb-NpAAA8Z046dYQ917.png "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/get_mysql_stats_wrapper.sh 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://s5.51cto.com/wyfs02/M02/9F/58/wKioL1mbu82Ago3CAAAwrXIP3Ho725.png "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 192.168.60.211-k mysql.key-read-requests

Normal output:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9F/58/wKioL1mbu9fyAfkSAAAswEbXzfY902.png "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://s2.51cto.com/wyfs02/M02/9F/58/wKioL1mbvCDCGeCsAACKzhCW6gU819.png "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:

Https://www.percona.com/doc/percona-monitoring-plugins/LATEST/zabbix/index.html

This article is from the "Start Linux blog" blog, make sure to keep this source http://qicheng0211.blog.51cto.com/3958621/1958291

Zabbix:percona How to use MySQL Monitor plugin

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.