4

Zabbix生产案例实战五——使用Percona监控插件监控MySQL

 2 years ago
source link: https://chegva.com/1176.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Zabbix生产案例实战五——使用Percona监控插件监控MySQL

Zabbix使用Percona监控插件监控MySQL

▏工作原理

  • 通过shell脚本调用定义的php脚本来作数据采集,然后将数据传递到zabbix

1 下载Percona监控插件模版并配置

[root@linux-node1 ~]# yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm 
[root@linux-node1 ~]# yum install percona-zabbix-templates php php-mysql
[root@linux-node1 ~]# rpm -ql percona-zabbix-templates 
/var/lib/zabbix/percona
/var/lib/zabbix/percona/scripts
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh    #shell脚本,用来调用php脚本
/var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php        #采集数据的php脚本
/var/lib/zabbix/percona/templates
/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf    #拷贝到zabbix配置目录下
/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml    #将模版导入到zabbix中
[root@linux-node1 ~]# cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

2 创建监控MySQL的配置文件

[root@linux-node1 ~]# cd /var/lib/zabbix/percona/scripts/
[root@linux-node1 /var/lib/zabbix/percona/scripts]# vi ss_get_mysql_stats.php.conf
<?php
$mysql_user = 'root'
$mysql_pass = 'rootroot';
#测试连接数据库,注意权限问题和sh中mysql的路径问题,必须有Php环境
[root@linux-node1 /var/lib/zabbix/percona/scripts]# ./get_mysql_stats_wrapper.sh  gm
1
[root@linux-node1 /tmp]# zabbix_get -s 192.168.56.11 -k MySQL.max-connections
151
[root@linux-node1 /tmp]# ll /tmp/localhost-mysql_cacti_stats.txt     #采集数据保存的文件
-rw-rw-r-- 1 zabbix zabbix 1407 Oct  3 00:49 /tmp/localhost-mysql_cacti_stats.txt

3 主机添加MySQL监控模版,添加图形

anzhihe安志合个人博客,版权所有丨 如未注明,均为原创 丨转载请注明转自:https://chegva.com/1176.html | ☆★★每天进步一点点,加油!★★☆

book.png 您可能还感兴趣的文章!

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

评论

姓名 *

电子邮件 *

站点

Save my name, email, and website in this browser for the next time I comment.

© 2016-2021 安志合 版权所有 | 订阅 | 站点统计 | 京 ICP17028760 | 由WordPress自豪地提供. Theme: Flat by Themeisle.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK