码迷,mamicode.com
首页 > 数据库 > 详细

zabbix监控mysql

时间:2016-05-13 05:01:58      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:zabbix监控mysql

1.在mysql端(zabbix客户端)修改监控mysql的参数

[root@db01 ~]# vim /etc/my.cnf
[mysql]
auto-rehash
user=用户名
password=密码


[mysqladmin]
user=用户名

password=密码

[root@db01 ~]# vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
UserParameter=mysql.status[*],echo "show global status where Variable_name=‘$1‘;" | /usr/local/mysql-5.6.28/bin/mysql -S /tmp/mysql.sock -N | awk ‘{print $$2}‘
UserParameter=mysql.size[*],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‘");" | /usr/local/mysql-5.6.28/bin/mysql -S /tmp/mysql.sock -N

UserParameter=mysql.ping,/usr/local/mysql-5.6.28/bin/mysqladmin -S /tmp/mysql.sock ping | grep -c alive
UserParameter=mysql.version,/usr/local/mysql-5.6.28/bin/mysql -S /tmp/mysql.sock -V

[root@db01 ~]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent:       [  OK  ]
Starting Zabbix agent:            [  OK  ]
[root@db01 ~]#

2.在zabbix服务端测试命令

[root@db02 ~]# zabbix_get -s mysql的IP地址 -k "mysql.version"
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
[root@db02 ~]# zabbix_get -s mysql的IP地址 -k "mysql.ping"
0
[root@db02 ~]#

3.在zabbix控制台要监控的主机上附加mysql模板

技术分享


4.绘制的图形

技术分享

技术分享

本文出自 “一起走过的日子” 博客,请务必保留此出处http://tongcheng.blog.51cto.com/6214144/1772671

zabbix监控mysql

标签:zabbix监控mysql

原文地址:http://tongcheng.blog.51cto.com/6214144/1772671

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!