This article mainly introduces the configuration of Zabbix monitoring MySQL, including the use of Zabbix self-contained templates to monitor MySQL related information and custom key monitoring MySQL synchronization. at the same time, it introduces the creation of Trigger and Zabbix by mail.
First, configure the self-brought template monitoring MySQL
1. Provision Profile Template
File location in Source package /usr/local/src/zabbix-3.0.4/conf/zabbix_agentd/userparameter_mysql.conf
1 |
#cp/usr/local/src/zabbix-3.0.4/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d |
2. Modify the template file
1 |
#sed -i ‘[email protected]/var/lib/[email protected]/usr/local/zabbix/[email protected]‘ /usr/local/zabbix/etc/zabbix_agentd.conf.d/userparameter_mysql.conf |
The modified file
Userparameter=mysql.status[*],echo "show global status where Variable_name= ' $ ';" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql-n | awk ' {print $$2} '
Userparameter=mysql.size[*],bash-c ' echo ' Select SUM ($ (case "$ both|" "") echo "Data_length+index_length";; Data|index) echo "$3_length";; Free) echo "Data_free";; ESAC)) from information_schema.tables$ ([["$" = "All" | |! "$"] | | echo "Where table_schema=\" $1\ "") $ ([[["$] =" All "| |! "$"] | | echo "and table_name=\" $2\ ""); "| Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql-n '
Userparameter=mysql.ping,home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysqladmin Ping | Grep-c Alive
Userparameter=mysql.version,/usr/local/mysql/bin/mysql-v
3.< Span style= "Font-family:simsun;" lang= "ZH-CN" xml:lang= "ZH-CN" > provide file for the agent-attached database
1234567891011 |
#vi /usr/local/zabbix/etc/.my.cnf [mysql ] host=localhost user=zabbixagent password=123456 socket= /tmp/ MySQL .sock [mysqladmin] host=localhost user=zabbixagent password=123456 socket= /tmp/mysql .sock |
4. create an authorized account
12 |
mysql> GRANT USAGE,PROCESS,REPLICATION CLIENT,REPLICATION SLAVE ON *.* TO ‘zabbixagent‘ @ ‘localhost‘ IDENTIFIED BY ‘123456‘ ; mysql> flush privileges; |
5. Modify zabbix_agentd.conf
include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
Restart Service
6. associating MySQL templates in the Web interface
7. Final Effect
Second, the custom key monitoring slave
1. provide a configuration file for monitoring slave
#cat/usr/local/zabbix/etc/zabbix_agentd.conf.d/mysql_slave.conf
Userparameter=mysql.slave.seconds_behind_master,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "Seconds_behind_master" |awk ' {print $} '
Userparameter=mysql.slave.slave_io_running,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "slave_io_running" |awk ' {print $} '
Userparameter=mysql.slave.slave_sql_running,echo "show Slave Status\g" | Home=/usr/local/zabbix/etc/usr/local/mysql/bin/mysql |grep "\<slave_sql_running\>" |awk ' {print $} '
2. Restart Agent service
# Service Zabbix_agentd Restart
3. command to test the value obtained by key
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Seconds_Behind_Master"
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Slave_IO_Running"
#/usr/local/zabbix/bin/zabbix_get-s 192.168.1.16-k "Mysql.slave.Slave_SQL_Running"
The above command returns the normal value description of the custom key success
4. Configuring monitoring items in the Web interface
Create slave delay items
Create Slave IO threads items
Create Slave SQL Threads items
Third, master-slave synchronization delay Alarm configuration
1. Defining triggers
Creating a master-slave delay Trigger
2. define the action
3. define mail sending users
To modify the mail server address for the alert media type
User linked to the alert media and set up the email account
View Mail
e-Mail specific content
Four, master-slave synchronization State Alarm configuration
1. Create a master-slave synchronization state trigger
Define IO Thread Status
Define SQL Thread Status
2. Testing
Stop IO threads and SQL threads separately on slave
Analog Stop IO Thread
mysql> stop slave Io_thread;
Simultaneous alarm message issued
Recovering IO Threads
mysql> start slave io_thread;
Recovery notification messages
Simulate stopping SQL threads
mysql> stop slave Sql_thread;
Simultaneous alarm message issued
Recovering SQL Threads
mysql> start slave sql_thread;
Recovery notification messages
http://hnr520.blog.51cto.com/4484939/1852838
Zabbix monitoring MySQL configuration and fault alarm configuration