Skip to content

Instantly share code, notes, and snippets.

@s-hironobu
Created July 17, 2014 00:41
Show Gist options
  • Select an option

  • Save s-hironobu/fd12aea9617c5f170c1a to your computer and use it in GitHub Desktop.

Select an option

Save s-hironobu/fd12aea9617c5f170c1a to your computer and use it in GitHub Desktop.
zabbix UserParameter for MySQL slave status
UserParameter=mysql.slave,mysql --defaults-extra-file=/var/lib/zabbix/.my.cnf -e "SHOW SLAVE STATUS\G"|awk 'BEGIN{io="None";sql="None"}{if($1 ~/^Slave_IO_Running:$/){io=$2}else if($1 ~/^Slave_SQL_Running:$/){sql=$2}}END{if(io=="Yes" && sql=="Yes"){ret=0}else if(io=="No" && sql=="Yes"){ret=2}else if(io=="Yes" && sql=="No"){ret=3}else if(io=="No" && sql=="No"){ret=4}else if(io=="Connecting"){ret=1}else{ret=5};print ret}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment