Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. # MySQL replication monitoring tool for Zabbix 3
  2.  
  3. # How to use
  4. # Item:
  5. # type:Zabbix agent
  6. # mysqlrepl.single # no args
  7. # mysqlrepl.multi # no args
  8. # "0" will be returned if replication is working
  9.  
  10. ## How to Use on Zabbix Web
  11. ## Set these items on zabbix admin pages
  12. #
  13. ## Prerequisite:
  14. ## Firstly, place /root/.my.cnf like this;
  15. #
  16. # [client]
  17. # user=root
  18. # password="p@$$"
  19.  
  20. ## Case: Multiple replications
  21. ### mysqlrepl.multi
  22. #### test command(Excute on zabbix-server shell)
  23. #### $ zabbix_get -s 192.168.1.33 -k "mysqlrepl.multi"
  24. #### 0 means success. Result of "status" will be returned when failed.
  25. #
  26. ## Case: Single replications
  27. ### mysqlrepl.single
  28. #### test command(Excute on zabbix-server shell)
  29. #### $ zabbix_get -s 192.168.1.3 -k "mysqlrepl.single"
  30. #### 0 means success. Result of "status" will be returned when failed.
  31.  
  32. # multi Replication
  33. 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"
  34.  
  35. # single Replication
  36. 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