标签:
PMP,全称是Percona Monitoring Plugins,是Percona公司为MySQL监控写的插件。支持Nagios,Cacti。从PMP 1.1开始,支持Zabbix。
下面,看看如何在Zabbix上安装PMP。
配置Zabbix Agent
下载PMP
下载地址:https://www.percona.com/downloads/percona-monitoring-plugins/
因为我的Linux版本是RHEL 6.7,故选择RPM包
# wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.6/percona-zabbix-templates-1.1.6-1.noarch.rpm
# rpm -ivh percona-zabbix-templates-1.1.6-1.noarch.rpm
warning: percona-zabbix-templates-1.1.6-1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY Preparing... ########################################### [100%] 1:percona-zabbix-template########################################### [100%] Scripts are installed to /var/lib/zabbix/percona/scripts Templates are installed to /var/lib/zabbix/percona/templates
拷贝PMP的配置文件
# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
确保Zabbix-Agent配置文件中已经开启Include=/etc/zabbix/zabbix_agentd.d/
重启Zabbix-Agent服务
# service zabbix-agent restart
创建MySQL的监控用户
mysql> grant process,super,select on *.* to monitor@‘localhost‘ identified by ‘monitor‘;
mysql> flush privileges;
修改脚本中的用户名和密码
# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
$mysql_user = ‘monitor‘; $mysql_pass = ‘monitor‘; $mysql_port = 3306;
测试脚本能否获取到数据库的状态信息
该脚本需测试两部分内容
1. MySQL实例本身的状态变量
2. MySQL是否为Slave
测试MySQL实例本身的状态变量
# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: line 35: /usr/bin/php: No such file or directory 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
因为它的脚本是用PHP实现的,故需要安装php和php-mysql
# yum install php php-mysql
重新测试该脚本
# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
有值返回就代表OK
测试MySQL是否为Slave
# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh running-slave
返回0和1是正常值,返回“Access denied”则有问题。
导入PMP的模板
即/var/lib/zabbix/percona/templates目录中的zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml
标签:
原文地址:http://www.cnblogs.com/ivictor/p/5803415.html