Zabbix monitors mysql and zabbixmysql
I. System Environment
Operating System: centos 7
Zabbix version: 3.2.5
Ii. Install the zabbix Client
# Wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch. rpm
# Yum-y install zabbix-release-3.2-1.el7.noarch
# Yum-y install zabbix-agent
Configuration File
/Etc/zabbix/zabbix_agentd.conf
Iii. Single Point Mysql monitoring module 3.1 Template App MySQL
Zabbix provides an official Template for monitoring mysql App MySQL. You can see the related Items and keys.
3
. 2Run the mysql command to view information.
Link the Template App MySQL to the relevant host and find that the Item Status is unavailable, because the key value is obtained by viewing the "show global status" information by Mysql users or by using the mysqladmin command to view status or extended-status information.
3.3 shell script
# Vim/data/monitor/mysql_zabbix.sh
!/bin/bash# # 2017/04/27MYSQL_PWD='Your_password'ARGS=1if [ $# -ne "$ARGS" ];thenecho "Please input onearguement:" ficase $1 inUptime)result=` mysqladmin -uroot -p${MYSQL_PWD} status 2>/dev/null|awk '{print $2}'`echo $result;;Questions)result=`mysqladmin -uroot -p${MYSQL_PWD} status 2>/dev/null|awk '{print $6}'`echo $result;;Com_update)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_update"|awk '{print $4}'`echo $result;;Slow_queries)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Slow_queries"|awk '{print $4}'`echo $result;;Com_select)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_select"|awk '{print $4}'`echo $result;;Com_rollback)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_rollback"|awk '{print $4}'`echo $result;;Com_insert)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_insert"|awk '{print $4}'`echo $result;;Com_delete)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_delete"|awk '{print $4}'`echo $result;;Com_commit)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_commit"|awk '{print $4}'`echo $result;;Bytes_sent)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Bytes_sent"|awk '{print $4}'`echo $result;;Bytes_received)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Bytes_received"|awk '{print $4}'`echo $result;;Com_begin)result=`mysqladmin -uroot -p${MYSQL_PWD} extended-status 2>/dev/null|grep -w "Com_begin"|awk '{print $4}'`echo $result;;*)echo "Usage:$0(Uptime|Questions|Com_update|Slow_queries|Com_select|Com_rollback|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin)";;esac
# Chmod a + x/data/monitor/mysql_zabbix.sh
3.4 modify the configuration file of zabbix
Centos7 client Configuration
# Vim/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
UserParameter = mysql. ping, mysqladmin-uroot-p111111 ping | grep-c alive
UserParameter = mysql. version, mysql-V
UserParameter = mysql. status [*],/data/monitor/mysql_zabbix.sh $1
Mysql. status [*] indicates the key value of the check command when zabbix detects the mysql status. * indicates all check options. For details, refer to the project in the Template App MySQL Template:
3.5 test script
On the zabbix server:
# Zabbix_get location on your server
Test successful
4. Add zabbix monitoring 4.1 to create mysql host groups and hosts
Configuration ---> Host group ---> Create Host group (MySQL)
Configure ---> host ---> Create host
4.2 Add the host to the template
After the configuration is complete, the image will actually come out. If the image has no data, delete the default image and add it again according to the original configuration.