zabbix 执行自定义key脚本超时


报错如下:

[root@master scripts]# /usr/local/zabbix/bin/zabbix_get -s 127.0.0.1 -k web.site.code[www.baidu.com]
timeout while executing a shell script
 

解决:

vim zabbix_server.conf
 

中调整如下超时时间即可(再重启server)

### Option: Timeout

#   Specifies how long we wait for agent, SNMP device or external check (in seconds).

#

# Mandatory: no

# Range: 1-30

# Default:

# Timeout=3

Timeout=30

   

vim zabbix_agentd.conf
 

### Option: Timeout

#   Spend no more than Timeout seconds on processing

#

# Mandatory: no

# Range: 1-30

# Default:

# Timeout=3

Timeout=30

当脚本执行时间确实操作了最大的timeout时间的呢?

解决方案:使用zabbix_send直接定期主动的发送的zabbix server不通过zabbix server去采集。

操作选项:

agent.version 

-z --zabbix-server server  Hostname or IP address of Zabbix server or proxy

                             to send data to.

-s --host host

-k --key key

-o --value value

-i --input-file input-file

-v --verbose

注意

1:

-z 选项一定要指定,可以使用server name(可解析)或者server name的IP地址

-s 指定agent的主机名,不能使用IP地址,且不能使用dnsname,一定要使用zabbix 前端设定的那个Hostname。如果-c指定了config配置文件,则配置文件中的Hostname将覆盖-s 指定的。也就是说知道了

-c,就可以不用指定-s

-k 要发送个那个key数据的。item key

-o value key的值。

2 每执行一次send,数据就会被传说到zabbix server,就会被立马展示在server端下的这个主机的key value中。

3 使用这种send方式更新的zabbix item key一定要是主动方式监控的key。被动的item项目是不支持这个方式的。

如:【针对某一个key item做测试】

zabbix_sender -z 10.59.74.33 -s dev-vhost012  -k system.swap.size[,pfree] -o 3

或者

zabbix_sender -v -c /data1/env/zabbix30/etc/zabbix_agentd.conf -z 10.59.74.33  -k system.swap.size[,pfree] -o 4

info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000072"

sent: 1; skipped: 0; total: 1

【如何针对批量主动发送key -value 到zabbix server】

-i --input-file 的用法

# cat zabbix_send_test.txt 

dev-vhost012 system.swap.size[,free] 32

dev-vhost012 system.swap.size[,pfree] 5

dev-vhost012 system.cpu.util[,idle] 11

注意格式是<host> <key> <value> 以空白符隔开。

# /data1/env/zabbix30/bin/zabbix_sender -v -c /data1/env/zabbix30/etc/zabbix_agentd.conf -z 10.59.74.33 -i zabbix_send_test.txt 

info from server: "processed: 3; failed: 0; total: 3; seconds spent: 0.000140"

sent: 3; skipped: 0; total: 3

原文地址:https://www.cnblogs.com/wangmo/p/9681693.html