There is a built-in template to monitor MySQL at Zabbix. To monitor the slave using Zabbix, there are no built-in templates. If you are monitoring MySQL using a built-in template, slave connection status can be monitored by doing some simple changes in the userparameter_mysql.conf file, creating an item & trigger.
Changes of userparameter_mysql.conf
Go to the directory -
/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
Add the following line -
UserParameter=mysql.slavestatus[*],echo “show slave status \G;” | HOME=”Path of credentials” mysql | grep ‘$1’ | awk ‘{print $$2}’ | sed -e ‘s/^NULL$/-1/’
- My credentials are stored in /etc/zabbix/.my.cnf
Create an item
Go to Host -> Items -> Create item
Fill the fields by followings data -
a) Type: Zabbix agent
b) Key :
mysql.slavestatus[Slave_IO_Running]
#Parameters like “Slave_IO_Running” ,“Slave_SQL_Running” etc can be used
c) Type of information: Text
d) Application: MySQL
Create a trigger
Go to Host -> Triggers -> Create trigger
Fill the field by followings data -
Expression =
{Host name:mysql.slavestatus[Slave_IO_Running].str(Yes)}=0
#Parameters like “Slave_IO_Running” ,“Slave_SQL_Running” etc
By these three steps, the slave can be monitored easily.