Home  >  Article  >  Backend Development  >  zabbix自定义key测试失败

zabbix自定义key测试失败

WBOY
WBOYOriginal
2016-06-06 20:40:131486browse

要做一个很简单的收集系统内存使用情况的监控,根据网上各种资料获得方法如下:
修改zabbix_agentd.conf中的几个配置

<code>UnsafeUserParameters=1
UserParameter=mem.usage,/usr/bin/free -m |grep Mem | awk '{print $3}'
</code>

然后zabbix_agentd -t mem.usage,返回报错

<code>mem.usage                                     [m|ZBX_NOTSUPPORTED] [Unsupported item key.]
</code>

试过另外一个感觉一样的方法:
修改zabbix_agentd.conf中的几个配置

<code>UnsafeUserParameters=1
Include=/app/local/zabbix/conf/zabbix_agentd/*.conf
</code>

然后在/app/local/zabbix/conf/zabbix_agentd/中创建mem_usage.conf文件

mem_usage.conf中的内容为

<code>UserParameter=mem.usage,HOME=/app/local/zabbix/sh/mem_usage.sh
</code>

在/app/local/zabbix/sh/中创建mem_usage.sh文件,内容为

<code>#!/bin/bash
/usr/bin/free -m |grep Mem |awk '{print $3}'
</code>

运行此脚本能正确返回结果,但使用zabbix_agentd -t mem.usage,返回报错

<code>mem.usage                                     [m|ZBX_NOTSUPPORTED] [Unsupported item key.]
</code>

求大神指点。。。。

回复内容:

要做一个很简单的收集系统内存使用情况的监控,根据网上各种资料获得方法如下:
修改zabbix_agentd.conf中的几个配置

<code>UnsafeUserParameters=1
UserParameter=mem.usage,/usr/bin/free -m |grep Mem | awk '{print $3}'
</code>

然后zabbix_agentd -t mem.usage,返回报错

<code>mem.usage                                     [m|ZBX_NOTSUPPORTED] [Unsupported item key.]
</code>

试过另外一个感觉一样的方法:
修改zabbix_agentd.conf中的几个配置

<code>UnsafeUserParameters=1
Include=/app/local/zabbix/conf/zabbix_agentd/*.conf
</code>

然后在/app/local/zabbix/conf/zabbix_agentd/中创建mem_usage.conf文件

mem_usage.conf中的内容为

<code>UserParameter=mem.usage,HOME=/app/local/zabbix/sh/mem_usage.sh
</code>

在/app/local/zabbix/sh/中创建mem_usage.sh文件,内容为

<code>#!/bin/bash
/usr/bin/free -m |grep Mem |awk '{print $3}'
</code>

运行此脚本能正确返回结果,但使用zabbix_agentd -t mem.usage,返回报错

<code>mem.usage                                     [m|ZBX_NOTSUPPORTED] [Unsupported item key.]
</code>

求大神指点。。。。

修改zabix-agentd.conf后需要重新启动一下,然后可以使用zabbix自带的软件来测试一下自定义KEY

<code>zabbix-get -s agent_ip -p 10050 -k mem.usage
</code>

版本不同,导致的坑爹货!
https://www.zabbix.com/documentation/3.0/manual/config/items/userparameters/extending_agent

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn