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的性能数据进行显示

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native