使用zabbix监控mysql

实验环境

localhost:   zabbix agent
 server2:    zabbix server

一·安装以及修改配置文件

[root@localhost ~]# ls
percona-zabbix-templates-1.1.8-1.noarch.rpm
[root@localhost ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm 
[root@localhost ~]# cd /var/lib/zabbix/percona/scripts/
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@localhost scripts]# cd /var/lib/zabbix/percona/templates/
[root@localhost templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[root@localhost templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
[root@localhost templates]# cd /etc/zabbix/zabbix_agentd.d/
[root@localhost zabbix_agentd.d]# ls
userparameter_mysql.conf  userparameter_percona_mysql.conf
[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent
[root@localhost templates]# cd /var/lib/zabbix/
[root@localhost zabbix]# ls
percona
[root@localhost zabbix]# cd percona/scripts/
[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@localhost scripts]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf    # 添加内容
[root@localhost scripts]# cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf 
<?php
$mysql_user = 'root';
$mysql_pass = 'westos';

这里写图片描述

二·登陆mysql是否登陆成功

这里写图片描述

[root@localhost scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php  ss_get_mysql_stats.php.cnf
[root@localhost scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
0
[root@localhost scripts]# cd /tmp/
[root@localhost tmp]# ls
[root@localhost tmp]# cat localhost-mysql_cacti_stats.txt 
[root@localhost tmp]# ls
localhost-mysql_cacti_stats.txt
[root@localhost tmp]# rm -fr localhost-mysql_cacti_stats.txt   #查看后需要删除

这里写图片描述
这里写图片描述

root@localhost ~]# vim ~zabbix/.my.cnf 
[root@localhost ~]# cat ~zabbix/.my.cnf 
[client]
user = root
password = westos
[root@localhost ~]# systemctl restart zabbix-agent
[root@localhost tmp]# netstat -antlp | grep 10050

这里写图片描述

[root@localhost ~]# cd /etc/zabbix/
[root@localhost zabbix]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Threads-cached'

这里写图片描述

三·在网页中添加Mysql

在网页中导入文件
这里写图片描述
这里写图片描述
添加Mysql模块
这里写图片描述

浏览图形
这里写图片描述
这里写图片描述
查看监控项
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值