模板MySQL没有得到Zabbix的结果

时间:2016-01-21 07:37:06

标签: mysql templates zabbix

我打算使用Temple MySQL 监视MySQL详细信息实例。不幸的是,我无法得到结果。我在配置中仍然缺少什么。检查一下zabbix-agent日志那些是日志而不是整个日志。

XECUTE_STR() command:'/usr/lib/zabbix/externalscripts/mysql_check.pl' len:0 cmd_result:''
 28786:20160121:141008.072 Sending back []
 28786:20160121:141008.072 listener #2 [waiting for connection]
 28788:20160121:141008.648 In send_buffer() host:'127.0.0.1' port:10051 values:0/100
 28788:20160121:141008.648 End of send_buffer():SUCCEED
 28788:20160121:141008.648 active checks #1 [idle 1 sec]
 28784:20160121:141008.795 collector [processing data]
 28784:20160121:141008.796 In update_cpustats()
 28784:20160121:141008.796 End of update_cpustats()
 28784:20160121:141008.796 collector [idle 1 sec]
 28785:20160121:141009.075 listener #1 [processing request]
 28785:20160121:141009.075 Requested [mysql[root,Qwestions,lld]]

2 个答案:

答案 0 :(得分:1)

<强> 1。添加MySQL的特殊用户:

示例:

GRANT USAGE ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'superpassword';
FLUSH PRIVILEGES;

<强> 2。将用户参数添加到zabbix-agent配置

修改/etc/zabbix/zabbix_agentd.conf

UserParameter=mysql.version,mysql -V
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/etc/zabbix mysql -N | awk '{print $$2}'
UserParameter=mysql.ping,HOME=/etc/zabbix mysqladmin ping | grep -c alive
# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
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'");" | HOME=/etc/zabbix mysql -N

如果要扩展监控项,只需使用正确的SQL查询添加另一个UserParameter

第3。添加MySQL的auth文件:

.my.cnf文件创建为/etc/zabbix/

[client]
user = zabbix
password = superpassword

<强> 4。重新启动代理(如果使用,则使用zabbix-proxy)

答案 1 :(得分:0)

日志没用。我们看到只有脚本没有返回结果,并且无法理解原因。

  1. 尝试使用您在mysql_check.pl文件中提供的凭据从控制台连接到MySQL。确保用户拥有足够的权限(最后是SUPER)。
  2.   

    mysql -hhostname -uuser -ppassword

    1. 从用户zabbix运行脚本并检查结果:
    2.   

      perl ./mysql_check.pl