标签:cto space mysql false UI tle format 监控服务 tab
1.GUI界面添加Mysql模板Configuration --> Hosts --> 点击要添加的主机 --> Templates
添加新的模板,点击Select -->选择”Template DB MySQL“
点击“add”添加,最后点击Update更新;
2.登陆MySQL服务,创建只读账户;
mysql> grant select on *.* to "zabbix"@"localhost" identified by “123456”; #赋权 mysql> flush privileges; #刷新权限
3.修改mysql服务器的agent配置
# cd /etc/zabbix/zabbix_agentd.d # cp userparameter_mysql.conf{,.bak} # vim userparameter_mysql.conf 5 UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix /data/mysql/bin/mysql -N | awk '{print $$2}' 15 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 informat ion_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix /data/mysql/bi n/mysql -N' 16 17 UserParameter=mysql.ping,HOME=/var/lib/zabbix /data/mysql/bin/mysqladmin ping | grep -c alive 18 UserParameter=mysql.version,/data/mysql/bin/mysql -V
注:1.mysql和mysqladmin配上绝对路径;
2./var/lib/zabbix改为/usr/local/zabbix/etc;作为存放.my.cnf文件的位置;
# mkdir -pv /usr/local/zabbix/etc # vim /usr/local/zabbix/etc/.my.cnf \# mysql_agent #文件内容 [mysql] host=localhost user=zabbix password=123456 socket=/data/mysql/mysql.sock [mysqladmin] host=localhost user=zabbix password=123456 socket=/data/mysql/mysql.sock # service zabbix-agent restart # ss -tnl | grep 10050
4.GUI 界面
查看MySQL模板监控是否生效:
Configuration --> Hosts --> 点击要监控服务器的Items选项 -->
Application选择MySQL,点击Apply过滤掉其它监控项;查看mysql模板监控是否生效;如图:
Monitoring --> Latest data -->
Hosts选择要监控的那台MySQL服务器;Application选择MySQL;点击Allly;如图:
查看监控图像:
Monitoring --> Graphs -->
Host选择要监控的那台MySQL服务器;Graph选择MySQL operations;如图:
标签:cto space mysql false UI tle format 监控服务 tab
原文地址:http://blog.51cto.com/moerjinrong/2062927