percona-zabbix-templates插件安装监控MySQL
前期准备:被监控机已经安装好php
1.在zabbix客户端安装mysql监控插件rpm包
rpm -ivh https://www.percona.com/downloads/percona-monitoring-plugins/1.1.6/percona-zabbix-templates-1.1.6-1.noarch.rpm
cd /var/lib/zabbix/percona/templates
cp userparameter_percona_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/ #(具体路径根据实际情况而定)
在zabbix监控页面中导入此模板文件 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml
2.编辑配置文件/usr/local/zabbix/etc/zabbix_agentd.conf
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
3.修改MySQL的执行命令文件 /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
RES=`HOME=~zabbix /usr/bin/mysql -uUSER -pPASS -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`
修改 /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php文件,换成自己MySQL的用户名和密码
$mysql_user = 'USER'; $mysql_pass = 'PASS';
4.在zabbix监控页面中添加MySQL监控,并选择Percona MySQL Server Template模板