注意事項:
實驗環境
CentOS Linux release 7.0.1406 (Core)
[root@localhost scripts]# mysql -v
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10683
Server version: 5.5.52-MariaDB MariaDB Server
因為我是在一臺服務器上做的,需要如下:
zabbix_agentd httpd mysqld zabbix_server
1、使用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
2、percona組成部分
PHP腳本
shell腳本去調用PHP腳本
zabbix配置文件
zabbix模板文件
3、安裝percona-zabbix模板 PHP PHP-MySQL
[root@localhost alertscripts]# yum install percona-zabbix-templates php php-mysql
4、查看具體安裝了什么軟件
[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]#
5、導入模板
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml
6、拷貝配置文件
[root@localhost alertscripts]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
7、腳本存放位置
[root@localhost scripts]# pwd
/var/lib/zabbix/percona/scripts
8、重啟服務
[root@localhost scripts]# systemctl restart zabbix-agent
9、創建一個配置文件,內容,用戶名,密碼。
<注意:生產環境中,需要創建一個監控用戶>
[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密碼為空,因為沒有設置)
9、打開配置文件查看監控的內容,根據需要獲取相應的參數
10、執行下腳本
[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
11、腳本中有點小BUG
11、配置主機添加模板,用慣了英文換會英文界面
然后查看圖形連接數
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。