使用Percona监控插件监控MySQL

Posted 滴滴滴--你不是爱拖延,而是爱逃避

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Percona监控插件监控MySQL相关的知识,希望对你有一定的参考价值。

 1.使用Percona监控插件监控mysql

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

https://www.percona.com/doc/percona-monitoring-plugins/1.1/zabbix/index.html#installation-instructions

yum install percona-zabbix-templates php php-mysql

 1.php脚本用来数据采集   2.shell  调用这个php   3.zabbix配置文件   4.zabbix模板文件      创建zabbix监控专用用户。

 

Percona Monitoring Plugins for Zabbix
These templates are mainly adopted from the existing Cacti ones. Currently, only MySQL template is available.

There are a few major differences between Cacti and Zabbix templates:

Zabbix does not support negative Y axis, that’s why you can see the negative values on some graphs to work out that - consider them the same as positive ones.
Zabbix does not support stacked graph items with mixed draw styles, that’s why some graphs may not look so nice like in Cacti as the stacks are replaced with lines.
Other Zabbix specific points:

The items are populated by polling Zabbix agent.
There are predefined triggers available to use.
There is a screen as a placeholder for all graphs.
300 sec. polling interval - like with Cacti, the existing PHP script is used to retrive and cache MySQL metrics except some trigger-specific items. Due to the caching of results, PHP script runs only once per period.
System Requirements
Zabbix version 2.0.x. The actual testing has been done on the version 2.0.9.
Zabbix agent, php, php-mysql packages on monitored node.
Installation Instructions
Configure Zabbix Agent
Install the package from Percona Software Repositories:

yum install percona-zabbix-templates
or:

apt-get install percona-zabbix-templates
It will place files under /var/lib/zabbix/percona/. Alternatively, you can grab the tarball and copy folders zabbix/scripts/ and zabbix/templates/ into /var/lib/zabbix/percona/. See below for the URL.
Copy Zabbix Agent config:

mkdir -p /etc/zabbix_agentd.conf.d/
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix_agentd.conf.d/userparameter_percona_mysql.conf
Ensure /etc/zabbix_agentd.conf contains the line: Include=/etc/zabbix_agentd.conf.d/
Restart Agent:

service zabbix-agent restart
Configure MySQL connectivity on Agent
On this step we need to configure and verify MySQL connectivity with localhost on the Agent node.

Create .cnf file /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf as described at configuration file

Example:

<?php
$mysql_user = ‘root‘;
$mysql_pass = ‘s3cret‘;
Test the script:

[[email protected] main]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
405647
Should return any number. If the password is wrong in .cnf file, you will get something like:

[[email protected] ~]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
ERROR: run the command manually to investigate the problem: /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
[[email protected] ~]# /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
ERROR: Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘ (2)[[email protected] ~]#
Configure ~zabbix/.my.cnf

Example:

[client]
user = root
password = s3cret
Test the script:

[[email protected] ~]# sudo -u zabbix -H /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
0
Should return 0 or 1 but not the “Access denied” error.
Configure Zabbix Server
Grab the latest tarball from the Percona Software Downloads directory to your desktop.
Unpack it to get zabbix/templates/ folder.
Import the XML template using Zabbix UI (Configuration -> Templates -> Import) by additionally choosing “Screens”.
Create/edit hosts by assigning them “Percona Templates” group and linking the template “Percona MySQL Server Template” (Templates tab).
You are done.
Support Options
If you have questions, comments, or need help with the plugins, there are several options to consider.

You can get self-service help via Percona’s forums, or the Percona mailing list.

You can report bugs and submit patches to the Launchpad project.

 

以上是关于使用Percona监控插件监控MySQL的主要内容,如果未能解决你的问题,请参考以下文章

使用percona监控插件在zabbix中监控MySQL

011-通过安装percona插件监控MySQL

zabbix:percona mysql监控插件使用方法

zabbix使用percona插件监控mysql

使用percona mysql插件来监控mysql5.7

使用 Percona 的 Zabbix 插件监控 MySQL