######################################################
Monitor MySQL ( default monitor template is not available, then agentd.conf to open the custom key, write your own script )
Add at the end of the zabbix_agentd.conf (note related file paths, and script permissions, etc.)
Vim zabbix_agentd.conf
Userparameter=mysql.version,mysql-v
Userparameter=mysql.ping,mysqladmin-uroot-p123456-s/tmp/mysql.sock Ping | Grep-c Alive
Userparameter=mysql.status[*],/tmp/checkmysql.sh $
Add The item template Template on the Web and choose the default.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7F/75/wKiom1cfJx2BfYujAABM5GAE4mM135.png "title=" Picture 1.png "alt=" Wkiom1cfjx2bfyujaabm5gae4mm135.png "/>
Writing a monitoring MySQL script
#!/bin/sh
#Create by Sfzhang 2014.02.20
mysql_sock= "/tmp/mysql.sock"
mysql_pwd=123456
Args=1
If [$#-ne "$ARGS"];then
echo "Please input one arguement:"
Fi
Case $ in
Uptime)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock status 2>/dev/null | Cut-f2-d ":" | cut-f1-d "T" '
Echo $result
;;
Com_update)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null | Grep-w "Com_update" | Cut-d "|"-f3 '
Echo $result
;;
Slow_queries)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock status 2>/dev/null |cut-f5-d ":" |cut-f1-d "O"
Echo $result
;;
Com_select)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_select" |cut-d "|"-f 3 '
Echo $result
;;
Com_rollback)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_rollback" |cut-d "|" -f3 '
Echo $result
;;
Questions)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock status 2>/dev/null |cut-f4-d ":" |cut-f1-d "s"
Echo $result
;;
Com_insert)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_insert" |cut-d "|"-f 3 '
Echo $result
;;
Com_delete)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_delete" |cut-d "|"-f 3 '
Echo $result
;;
Com_commit)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_commit" |cut-d "|"- F3 '
Echo $result
;;
Bytes_sent)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Bytes_sent" |cut-d "|"-f 3 '
Echo $result
;;
bytes_received)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Bytes_received" |cut-d " | "-f3"
Echo $result
;;
Com_begin)
result= ' Mysqladmin-uroot-p${mysql_pwd}-S $MYSQL _sock extended-status 2>/dev/null |grep-w "Com_begin" |cut-d "|"-f 3 '
Echo $result
;;
*)
#echo "Usage:$0 (uptime| com_update| slow_queries| Com_select| com_rollback| Questions) "
;;
Esac
###################################################
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/75/wKiom1cfJ4GST8z-AAHdaxi05eM147.png "title=" Picture 2.png "alt=" Wkiom1cfj4gst8z-aahdaxi05em147.png "/>
##############################################################
Monitoring MySQL master-slave replication
Vim zabbix_agentd.conf
Add at Trailer
Userparameter=mysql.replication,/tmp/mysqlzc.sh $
I created it myself. item is called mysqlzc
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/75/wKiom1cfKBWjdlcLAAD-psshHrg313.png "style=" float: none; "title=" Image 3.png "alt=" Wkiom1cfkbwjdlclaad-psshhrg313.png "/>
when creating a key, The key name should be the same as that added in the agent configuration file.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7F/75/wKiom1cfKBXTKamAAABAgZRV7Po029.png "style=" float: none; "title=" Image 4.png "alt=" Wkiom1cfkbxtkamaaabagzrv7po029.png "/>
The master-slave script requires only one command (note the path and permissions)
vim/tmp/mysqlzc.sh
#!/bin/bash
Mysql-uroot-p123456-e ' show slave status\g ' |grep-e ' slave_io_running| Slave_sql_running "|awk ' {print $} ' |grep-c Yes
This article is from the "full of Handsome Technology blog" blog, please be sure to keep this source http://manyushuai.blog.51cto.com/8818545/1767934
Zabbix Monitor MySQL performance, master-slave replication