Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. # How to Use
  2. #
  3. ## 1. Set this file on the servers which runs zabbix-agent
  4. ### $ cp this.sh /etc/zabbix/zabbix_agentd.conf.d/
  5. #
  6. ## 2. Set .my.cnf on the same server to login to mysql
  7. ### $ vi /var/lib/zabbix/.my.cnf
  8. #
  9. # [mysql]
  10. # host = localhost
  11. # user=YOURMYSQLUSER
  12. # password=YOURMYSQLPASSWORD
  13. # socket = /var/lib/mysql/mysql.sock
  14. #
  15. ## 3. Set zabbix item
  16. #
  17. ## For Multiple replication:
  18. ### > show slave 'REPLICATION_NAME' status;
  19. ### mysql.slave[master-db.com] # Add arg1 to replication name (CHANGE MASTER 'HERE' TO )
  20. #### Check command(Execute on zabbix-server)
  21. #### $ zabbix_get -s 192.168.1.2 -k "mysql.slave[master-db.com]"
  22. #### 0 means success. Returns slave status result if detects an error.
  23. #
  24. ## For Single(legacy) replication:
  25. ### > show slave status;
  26. ### mysql.slave[] # no args
  27. #### Check command(Execute on zabbix-server)
  28. #### $ zabbix_get -s 192.168.1.3 -k "mysql.slave[]"
  29. #### 0 means success. Returns slave status result if detects an error.
  30.  
  31. UserParameter=mysql.slave[*],[[ -z "$1" ]] && TARGET= || TARGET="'$1'" && CMDRES=$(mysql --defaults-extra-file=/var/lib/zabbix/.my.cnf -e "SHOW SLAVE $TARGET STATUS\G" | sed -e 's/^\s*//g' | sed 's/: /=/g' | tail -n +2 | sort ) && for j in $CMDRES; do eval export $j; done; RES=$Slave_IO_Running$Slave_SQL_Running; [[ $RES = "YesYes" ]] && echo 0 || echo "Replication check failed. 'SHOW SLAVE $TARGET STATUS;' Result => $CMDRES"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement