zabbix3.2.4监控MySQL5.7.16状态

一、添加监控用户
mysql> grant all privileges on *.* to 'zabbix'@'localhost' identified by 'zabbix';
mysql> flush privileges;

二、添加UserParameter
vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
加入如下内容:

UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/etc/zabbix mysql -N | awk '{print $$2}'
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'
UserParameter=mysql.ping,HOME=/etc/zabbix mysqladmin ping | grep -c alive

三、添加mysql连接信息
vim /etc/zabbix/.my.cnf

[mysql]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock
[mysqladmin]
host=localhost
user=zabbix
password=zabbix
socket=/tmp/mysql.sock

四、重启zabbix-agent服务
systemctl restart zabbix-agent

五、去zabbix的管理界面添加MySQL的监控

选在主机:

添加MySQL监控模板:

查看监控效果:

 

posted @ 2017-03-29 19:04  fansik  阅读(267)  评论(0编辑  收藏  举报