Zabbix application-Monitor MySQL slave master-slave status

Source: Internet
Author: User
Tags egrep

Online service Monitoring has been basically done, and now there is no detection of MySQL master-slave state, here to use Zabbix monitoring, but also to write a master-slave state script, and then set a key, create a template to apply this key to get MySQL master and slave state is normal.

1. Paste my script here, script to give executable permission

#!/bin/bashuser=zabbixagentpasswd=zabbixagentport=$1# Custom Function function  Status {   status= '/data/mysql_root/mysql/bin/mysql -u$user -s /data/mysql_ root/mysql/data$port/mysql.socket -p$passwd -e  "show slave status\g;"  | egrep  ' Slave_io_running| Slave_sql_running '   | awk  ' {print $2} '  | egrep  ' Yes '  | WC  -l '     if [  $status  = 2 ];then         echo 2   else        echo  1   FI} #引用函数status 

2. Custom key

Cat/etc/zabbix/zabbix_agentd.d/check_mysql.conf

Userparameter=sanguo.check.mysql[*],/data/salt/scripts/check_mysql.sh $

Restart Zabbix_agent

3. Creating a template and linking the host

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/80/0A/wKioL1c1ftrjjYHQAADVHldTV0I219.png "title=" QQ picture 20160513145340.png "alt=" Wkiol1c1ftrjjyhqaadvhldtv0i219.png "/>


(1). Create Applications

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/0A/wKioL1c1fvKxDayyAABBEfK03cw851.png "title=" QQ picture 20160513145429.png "alt=" Wkiol1c1fvkxdayyaabbefk03cw851.png "/>

(2). Create items   Get the slave state of the 3316 instance, or use Zabbix_get-s ip-k sanguo.check.mysql[3316] on the server to get the value

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/0A/wKioL1c1fzCx76toAACd7zJulX8511.png "title=" Fd4f7dd2-9096-4f5e-ba37-b2873fb5a484.png "alt=" Wkiol1c1fzcx76toaacd7zjulx8511.png "/>


(3). Create trigger   trigger an alarm if the last obtained value is not equal to 2

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/0D/wKiom1c1fm-CSsmpAABnd-cgmPI224.png "title=" 22af8b5f-07f8-416d-8d0e-0e0587b2bdcc.png "alt=" Wkiom1c1fm-cssmpaabnd-cgmpi224.png "/>

(4). Create trigger action  

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/0D/wKiom1c1gBTD1BgqAABBT-CwHTY755.png "style=" float: none; "title=" Bc64c4ef-7b05-481a-9455-5cace43acbe1.png "alt=" Wkiom1c1gbtd1bgqaabbt-cwhty755.png "/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/0A/wKioL1c1gPbigyE7AACK1SAw8KA056.png "style=" float: none; "title=" E2d9cef3-a95a-4978-b226-688400eec8cb.png "alt=" Wkiol1c1gpbigye7aack1saw8ka056.png "/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/0D/wKiom1c1gBSBdVPzAABIhx0KdBU240.png "style=" float: none; "title=" E3674647-373d-4235-b525-d52483572961.png "alt=" Wkiom1c1gbsbdvpzaabihx0kdbu240.png "/>




Template in Attachment


This article from "Do not abandon!" Do not give up "blog, be sure to keep this source http://thedream.blog.51cto.com/6427769/1773036

Zabbix application-Monitor MySQL slave master-slave status

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.