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://xxxxxx/Linuxjc/1155301.html TechArticle