Centos 7下通过zabbix利用zabbix自有template监控mariadb

环境说明

Centos 7.2

zabbix 3.2

mariadb 5.5.50


操作步骤


此次通过zabbix自有template “Template APP MYSQL”对 zabbix-agent中的mariadb进行监控


1.安装zabbix-agent参考 《Centos 7下搭建Zabbix监控软件》


2.在安装完成zabbix-agent后,我们可以在/etc/zabbix/zabbix_agentd.d目录下面找到userparameter_mysql.conf文件,其内容如下

# For all the following commands HOME should be set to the directory that has .my.cnf file with password information.

# Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
# Key syntax is mysql.status[variable].
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'

# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
# Key syntax is mysql.size[<database>,<table>,<type>].
# Database may be a database name or "all". Default is "all".
# Table may be a table name or "all". Default is "all".
# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
# Database is mandatory if a table is specified. Type may be specified always.
# Returns value in bytes.
# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'

UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V

在修改该配置文件之前,我们需要在/var/lib/zabbix目录下面,新建maraidb数据库的配置文件[client]部分

[root@ovirt-host-227 zabbix_agentd.d]# vi /var/lib/zabbix/.my.conf 
[client]

user=root

password=123456

而后重启zabbix-agent

#systemctl restart zabbix-agent


3.我们在zabbix-server端,通过zabbix_get来测试下在zabbix-server端是否能获取在zabbix-agent中关于mariadb的数据

[root@centos7-zabbix-193 ~]# zabbix_get -s 10.10.200.227 -k mysql.status[Bytes_received]                                                                                                                                                                                  
2835903
[root@centos7-zabbix-193 ~]# zabbix_get -s 10.10.200.227 -k mysql.status[Com_update]                                                                                                                                                                                      
0

通过以上可以正确的获取mariadb的数据,下面在zabbix web console端配置Host端的Template

4.将“Template APP MySQL”加入Host的Template中




在加入后,我们分别查看item以及graphs





我们分别查看MySQL operations以及Mysql bandwidth



点击preview






点击preview



通过两个graphs均可将mariadb的性能数据进行显示。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值