문제

Is this possible to generate a new Zabbix event from a Ruby script? I was suggested to use zabbix_sender script, but I couldn't find any example.

Also, I couldn't find any API related to the events creation.

도움이 되었습니까?

해결책

First of all create some item of type zabbix trapper and then you can send some values to its name by zabbix_sender. You can send one value, or more collected data with timestamps. Here are docs.

Alternatively you can write own zabbix trap sender. Protocol is quite easy. I done the same in Python... no external commands.

다른 팁

Zabbix API does not allow item value updates by design.

I have investigated couple options* and my preferred way to update Zabbix item value from Ruby is using this approach found in miyucy's gist:

Example with simple error handler:

s = Zabbix::Sender.new 'zabbix_server', 10051

zabbix_resp = s.send('host', item_key, value)

if zabbix_resp["response"] != "success" or zabbix_resp["info"].split(';')[1] != " failed: 0"
  puts "error: zabbix responded with #{zabbix_resp} when trying to update #{item_key}"
end

*One example of alternative way - calling zabbix_sender binary

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top