Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # How to Use
- #
- ## 1. Set this file on the servers which runs zabbix-agent
- ### $ cp this.sh /etc/zabbix/zabbix_agentd.conf.d/
- #
- ## 2. Set .my.cnf on the same server to login to mysql
- ### $ vi /var/lib/zabbix/.my.cnf
- #
- # [mysql]
- # host = localhost
- # user=YOURMYSQLUSER
- # password=YOURMYSQLPASSWORD
- # socket = /var/lib/mysql/mysql.sock
- #
- ## 3. Set zabbix item
- #
- ## For Multiple replication:
- ### > show slave 'REPLICATION_NAME' status;
- ### mysql.slave[master-db.com] # Add arg1 to replication name (CHANGE MASTER 'HERE' TO )
- #### Check command(Execute on zabbix-server)
- #### $ zabbix_get -s 192.168.1.2 -k "mysql.slave[master-db.com]"
- #### 0 means success. Returns slave status result if detects an error.
- #
- ## For Single(legacy) replication:
- ### > show slave status;
- ### mysql.slave[] # no args
- #### Check command(Execute on zabbix-server)
- #### $ zabbix_get -s 192.168.1.3 -k "mysql.slave[]"
- #### 0 means success. Returns slave status result if detects an error.
- 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