要求:php
yum install php-cli php-mysql //由於它的監控插件腳本是php實現的因此須要安裝 yum install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm yum install percona-zabbix-templates -y
查看zabbix_agentd.conf文件,確保zabbix-Agent配置文件中開啓了Include=/etc/zabbix/zabbix_agentd.d/mysql
cat /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=127.0.0.1 ServerActive=127.0.0.1:10051 Hostname=kanshenmekan Include=/etc/zabbix/zabbix_agentd.d/*.conf EnableRemoteCommands=1 BufferSize=2048 Timeout=15 UnsafeUserParameters=1
拷貝PMP的配置文件sql
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
重啓zabbix服務socket
# service zabbix-agent restartide
建立mysql的監控用戶,只須要usage權限就能夠。測試
mysql>grant usage ON *.* TO 'zabbix'@'localhost' identified BY 'mimamimamima'; mysql> flush privileges;
修改腳本中的用戶名和密碼以及對應目錄插件
vi /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php $mysql_user = 'zabbix'; $mysql_pass = 'mimamimamima'; $mysql_port = 3306; $mysql_socket = "/data/mysql/mysql.sock";
若是socket沒有指定目錄須要建立軟鏈接。rest
而後就能夠測試數據code
cd /var/lib/zabbix/percona/scripts/ /usr/bin/php -q ./ss_get_mysql_stats.php --host localhost --items gg gg:557
最後還必須修改/tmp/localhost-mysql_cacti_stats.txt的權限ip
chown zabbix.zabbix /tmp/localhost-mysql_cacti_stats.txt
否則zabbix_get時會出現 Operation not permitted 操做不容許
有數據就能夠導入模板等出圖了。。。。