注意事項:php
實驗環境mysql
CentOS Linux release 7.0.1406 (Core)sql
[root@localhost scripts]# mysql -vshell
Welcome to the MariaDB monitor. Commands end with ; or \g.vim
Your MariaDB connection id is 10683服務器
Server version: 5.5.52-MariaDB MariaDB Serverapp
由於我是在一臺服務器上作的,須要以下:
ide
zabbix_agentd httpd mysqld zabbix_server spa
一、使用percona監控插件監控MySQL插件
[root@localhost alertscripts]# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
二、percona組成部分
PHP腳本
shell腳本去調用PHP腳本
zabbix配置文件
zabbix模板文件
三、安裝percona-zabbix模板 PHP PHP-MySQL
[root@localhost alertscripts]# yum install percona-zabbix-templates php php-mysql
四、查看具體安裝了什麼軟件
[root@localhost alertscripts]# rpm -qa php
[root@localhost scripts]# rpm -ql percona-zabbix-templates
/var/lib/zabbix/percona
/var/lib/zabbix/percona/scripts
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
/var/lib/zabbix/percona/templates
/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml
[root@localhost scripts]#
五、導入模板
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml
六、拷貝配置文件
[root@localhost alertscripts]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
七、腳本存放位置
[root@localhost scripts]# pwd
/var/lib/zabbix/percona/scripts
八、重啓服務
[root@localhost scripts]# systemctl restart zabbix-agent
九、建立一個配置文件,內容,用戶名,密碼。
<注意:生產環境中,須要建立一個監控用戶>
[root@localhost scripts]# vim ss_get_mysql_stats.php.cnf
[root@localhost scripts]# cat ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = 's3cret';(我這裏root密碼爲空,由於沒有設置)
九、打開配置文件查看監控的內容,根據須要獲取相應的參數
十、執行下腳本
[root@localhost scripts]# ./get_mysql_stats_wrapper.sh
得到的指標
[root@localhost scripts]# ./get_mysql_stats_wrapper.sh
7
4
4
4
2746
273953
1
20
0
0
8191
6663
1507
26
0
1507
十一、腳本中有點小BUG
十一、配置主機添加模板,用慣了英文換會英文界面
而後查看圖形鏈接數