CentOS under Zabbix Monitor mysql5.6 version master and slave

Source: Internet
Author: User
Tags egrep

The last Zabbix added monitoring MySQL performance, so this time on the basis of the addition of master-slave monitoring. In the course of the article is not introduced MySQL5.6 version of the relevant details of processing, specific reference to the previous article:
http://blog.csdn.net/ygqygq2/article/details/53264955

1. Zabbix Add a custom monitoring process
    1. Zabbix agentd Add a custom key;

    2. The custom key call is to get the monitoring data source script, etc.;

    3. Add Zabbix host data source template, host link template;

2. Concrete Step 1. Write monitoring MySQL master-slave script

vim/usr/local/zabbix/shell/check_mysql_slave.sh

#!/usr/bin/env bash#create by zijin 2014.09.28# #Need   "grant replication  client on *.* to [email protected] identified by  ' Zabbix ' "#Mysql5.6#  mysql_config_editor set --login-path=local --host=localhost --user=zabbix_select  -pmysql_sock= "/tmp/mysql.sock"  mysql_pwd= "Zabbix" mysql= "/usr/local/mysql/bin/mysql" MYSQL_ADMIN= "${ Mysql}admin "args=1 if [ $# -ne " $ARGS " ];then     echo   "Please input one arguement:"  fi case $1 in          slave_running)                   slave_is= ($ (sudo ${mysql} --login-path=local -s  $MYSQL _sock -e  "Show slave status\g" |egrep  "\bslave_.*_running\b" |awk  ' {print $2} '))    &Nbsp;            if [  "${slave_is[0]}"  =  "yes"  -a  "${slave_is[1]}"  =  "Yes"  ];then                      result= "1"                 else                       result= "0"                  fi                 echo  $result         ;;         seconds_behind)                  result=$ (sudo ${mysql} --login-path=local -s  $MYSQL _sock -e  "Show slave status\g" |egrep  "\bseconds_behind_master\b" |awk  ' {print $2} ')                  echo  $result         ;;         *)                   echo  "Usage:$0 (slave_running| Seconds_behind) "         ;;  esac  1234567891011121314151617181920212223242526272829303112345678910111213141516171819202122232425262728293031
2. mysql Empowering

grant REPLICATION CLIENT on *.* to [email protected] identified by ‘zabbix‘;

3. View script Execution effects
[Email protected] shell]# chmod a+x check_mysql_slave.sh [[email protected] shell]# sh check_mysql_slave.sh slave_runnin G 1[[email protected] shell]# sh check_mysql_slave.sh slave_seconds0[[e Mail protected] Shell #123456123456
4. Zabbix Client Add a custom key

vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/check_mysql_slave_key

Userparameter=mysql.slave[*],/usr/local/zabbix/shell/check_mysql_slave.sh $ $211
5. Add Zabbix monitor MySQL master-slave template

From the Zabbix page, import the templates template App MySQL slave.xml, the following link is the template address:
Https://github.com/ygqygq2/zabbix/blob/master/%E6%A8%A1%E6%9D%BF/Template%20App%20MySQL%20Slave.xml
650) this.width=650; "Src=" http://img.blog.csdn.net/20170122201559122?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvewdxewdxmg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "style=" Border:none;height:auto; "/>

6. Host link templates

650) this.width=650; "Src=" http://img.blog.csdn.net/20170122202350283?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvewdxewdxmg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "style=" Border:none;height:auto; "/>

7. View Results

View on Zabbi server side:

[[email protected] ~]# /usr/local/zabbix/bin/zabbix_get -s mysql-slave-ip -k   "Mysql.slave[seconds_behind]" 0[[email protected] ~]# /usr/local/zabbix/bin/zabbix_get  -s mysql-slave-IP -k  "mysql.slave[slave_running]"  112341234 

View on the page:
650) this.width=650; "Src=" http://img.blog.csdn.net/20170122202956583?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvewdxewdxmg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "alt=" here to write a picture describing "title=" "style=" Border:none;height:auto; "/>


This article is from the "YGQYGQ2" blog, make sure to keep this source http://ygqygq2.blog.51cto.com/1009869/1893783

CentOS under Zabbix Monitor mysql5.6 version master and slave

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.