The company MySQL architecture is a master multi-slave. In the daily use of the process we often encounter the main never sync, in order to deal with this problem in a timely manner using Zabbix monitoring MySQL master and slave state and set the trigger, if there is an exception to send mail alarm.
We all know that using the command "show slave status \g" can see the status of MySQL from, and the following script check its status.
In Mysql-slave, enter the Zabbix-agent directory to create the script file.
Cat mysql_slave_status.sh#!/bin/bash/usr/local/mysql/bin/mysql-uzabbix-e ' show slave status\g ' |grep-e "Slave_IO_ Running| Slave_sql_running "|awk ' {print $} ' |grep-c Yeschmod +x mysql_slave_status.sh
The execution mysql_slave_status.sh result is: 2
If the result is not 2 indicates master-slave synchronization exception, then the alarm!!
Note: Put the script in a directory (requires permission), I put it here to/etc/zabbix/mysql_slave_status.sh in the bottom of zabbix_agentd.conf, add the following statement:
userparameter=mysql.slavestatus,/etc/zabbix/mysql_slave_status.sh# The ZABBIX-AGENTD service must be restarted after the add is complete/etc/init.d/zabbix_ Agentd restart
The test succeeds after executing the following statement on the server where the Zabbix-server is located:
Zabbix_get-s 192.168.1.101-k Mysql.slavestatus
Where 192.168.1.101 is the server where the script resides, Mysql.slavestatus is the key value. Returning 2 indicates that the master-slave service is normal. Then the monitoring item in the Web platform test to add items, set up alarm notification can be.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8C/61/wKioL1hrGKmynPqhAACl1BzPCA0955.png-wh_500x0-wm_3 -wmp_4-s_1657839292.png "title=" 1.png "alt=" Wkiol1hrgkmynpqhaacl1bzpca0955.png-wh_50 "/>
Visit Zabbix---Find "configuration"-"host"-"project"--Create Project
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8C/64/wKiom1hrGfKgiBXJAACmrYBTSts118.png-wh_500x0-wm_3 -wmp_4-s_1674492486.png "style=" Float:none; "title=" 2.png "alt=" Wkiom1hrgfkgibxjaacmrybtsts118.png-wh_50 "/>
Enter the name of the monitoring item here-Data Update time
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8C/61/wKioL1hrGfKyYP7PAACwQ_-Llis016.png-wh_500x0-wm_3 -wmp_4-s_1029454949.png "style=" Float:none; "title=" 3.png "alt=" Wkiol1hrgfkyyp7paacwq_-llis016.png-wh_50 "/>
Next, create the trigger.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8C/64/wKiom1hrGfPzzTZ4AACjVg3RxwQ373.png-wh_500x0-wm_3 -wmp_4-s_650961017.png "style=" Float:none; "title=" 4.png "alt=" Wkiom1hrgfpzztz4aacjvg3rxwq373.png-wh_50 "/>
Trigger content note here The alarm is triggered when the value is less than 2, and the severity is set to "disaster"
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8C/61/wKioL1hrGfOhSpDLAACJA3t0QnQ924.png-wh_500x0-wm_3 -wmp_4-s_2386678758.png "style=" Float:none; "title=" 5.png "alt=" Wkiol1hrgfohspdlaacja3t0qnq924.png-wh_50 "/>
At this point, the Zabbix monitor MySQL master-slave status complete.
This article is from the "Snail Taunt" blog, please be sure to keep this source http://imork.blog.51cto.com/11642843/1888504
Monitor MySQL master-slave status using Zabbix