lib/logstash/outputs/zabbix.rb in logstash-output-zabbix-2.0.2 vs lib/logstash/outputs/zabbix.rb in logstash-output-zabbix-3.0.0

- old
+ new

@@ -102,11 +102,11 @@ end end # def register public def field_check(event, fieldname) - if !event[fieldname] + if !event.get(fieldname) @logger.warn("Field referenced by #{fieldname} is missing") false else true end @@ -140,14 +140,14 @@ # data. validated = validate_fields(event) data = [] (0..validated.length-1).step(2) do |idx| data << { - "host" => event[@zabbix_host], - "key" => event[validated[idx]], - "value" => event[validated[idx+1]], - "clock" => event["@timestamp"].to_i + "host" => event.get(@zabbix_host), + "key" => event.get(validated[idx]), + "value" => event.get(validated[idx+1]), + "clock" => event.get("@timestamp").to_i } end { "request" => "sender data", "data" => data, @@ -181,16 +181,16 @@ # ["processed", "0", "Failed", "1", "Total", "1", "seconds", "spent:", "0.000018"] failed = info[3].to_i total = info[5].to_i if failed == total @logger.warn("Zabbix server at #{@zabbix_server_host} rejected all items sent.", - :zabbix_host => event[@zabbix_host] + :zabbix_host => event.get(@zabbix_host) ) false elsif failed > 0 @logger.warn("Zabbix server at #{@zabbix_server_host} rejected #{info[3]} item(s).", - :zabbix_host => event[@zabbix_host] + :zabbix_host => event.get(@zabbix_host) ) false elsif failed == 0 && total > 0 true else @@ -235,10 +235,10 @@ end end public def receive(event) - + return unless field_check(event, @zabbix_host) send_to_zabbix(event) end # def event end # class LogStash::Outputs::Zabbix