您的位置:首页 > 数据库 > MariaDB

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

2016-12-05 13:30 393 查看

环境说明

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的性能数据进行显示。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: