percona插件监控mysql

一、下载模板工具

[root@linux-node2 ~]# wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.7-2.noarch.rpm

#在agent上面安装:
[root@linux-node2 ~]# rpm -ivh percona-zabbix-templates-1.1.7-2.noarch.rpm

二、配置文件和mysql的认证连接(we need to configure and verify MySQL connectivity with localhost on the Agent node)

[root@linux-node2 ~]# cat >>  /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf << END
$mysql_user = 'root';
$mysql_pass = '';
END

三、将/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh 脚本中的mysql换成/usr/local/mysql/bin/mysql
percona插件监控mysql_第1张图片

备注:如果用socket链接,还应指定socket的路径,即

[root@linux-node2 ~]# /usr/local/mysql/bin/mysql -S /usr/local/mysql/mysql.sock

四、将userparameter_percona_mysql.conf复制到zabbix_agentd的扩展配置文件目录下

[root@linux-node2 ~]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

五、测试:

[root@linux-node2 ~]#/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
21
[root@linux-node2 ~]#/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh kt
2778

percona插件监控mysql_第2张图片

备注:假如我们在测试的时候报错

[root@linux-node2 sbin]#/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

这里写图片描述

我们应该做一个软连接:

[root@linux-node2 sbin]# ln -s /usr/local/php/bin/php /usr/bin/php
[root@linux-node2 sbin]# /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
gg:21

重新测试,成功

六、将/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml 模板文件导入到zabbix的模板里面

percona插件监控mysql_第3张图片

percona插件监控mysql_第4张图片
导入成功。

备注:
如果在导入报错Invalid tag “/zabbix_export/date”:“YYYY-MM-DDThh:mm:ssZ” is expected.
解决:重新导入一个针对3.0的模版
http://download.csdn.net/detail/m0_37886429/9837275

你可能感兴趣的:(zabbix监控,mysql数据库)