Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # MySQL replication monitoring tool for Zabbix 3
- # How to use
- # Item:
- # type:Zabbix agent
- # mysqlrepl.single # no args
- # mysqlrepl.multi # no args
- # "0" will be returned if replication is working
- ## How to Use on Zabbix Web
- ## Set these items on zabbix admin pages
- #
- ## Prerequisite:
- ## Firstly, place /root/.my.cnf like this;
- #
- # [client]
- # user=root
- # password="p@$$"
- ## Case: Multiple replications
- ### mysqlrepl.multi
- #### test command(Excute on zabbix-server shell)
- #### $ zabbix_get -s 192.168.1.33 -k "mysqlrepl.multi"
- #### 0 means success. Result of "status" will be returned when failed.
- #
- ## Case: Single replications
- ### mysqlrepl.single
- #### test command(Excute on zabbix-server shell)
- #### $ zabbix_get -s 192.168.1.3 -k "mysqlrepl.single"
- #### 0 means success. Result of "status" will be returned when failed.
- # multi Replication
- UserParameter=mysqlrepl.multi,TARGET="show all slaves status\G;" && ERROR=0; CMDRES=$(mysql --defaults-extra-file=/root/.my.cnf -e "$TARGET" | grep Running | sed -e 's/^\s*//g' | sed 's/: /=/g' | sort ) && for j in $CMDRES; do eval export $j; [[ $j != *"Yes"* ]] && ERROR=1; done; [[ $ERROR != 1 ]] && echo 0 || echo -e "ERROR=$ERROR \nReplication check failed. \n'$TARGET' Result => \n\n$CMDRES"
- # single Replication
- UserParameter=mysqlrepl.single,TARGET="show slave status\G;" && CMDRES=$(mysql --defaults-extra-file=/root/.my.cnf -e "$TARGET" | grep Running | sed -e 's/^\s*//g' | sed 's/: /=/g' | sort ) && for j in $CMDRES; do eval export $j; done; RES=$Slave_IO_Running$Slave_SQL_Running; [[ $RES = "YesYes" ]] && echo 0 || echo -e "Replication check failed.\n '$TARGET' Result => \n\n$CMDRES"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement