Zabbix监控MySQL图文详解

因为我是在一台服务器上做的,需要如下:

zabbix_agentd httpd mysqld zabbix_server

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密码为空,因为没有设置)

10、打开配置文件查看监控的内容,根据需要获取相应的参数

11、执行下脚本
[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

12、脚本中有点小BUG

13、配置主机添加模板,用惯了英文换会英文界面

然后查看图形连接数

更多Zabbix相关教程集合

ZABBIX 的详细介绍请点这里
ZABBIX 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2017-06/144952.htm