Skip to content

Commit

Permalink
Update to use Java Event set and get
Browse files Browse the repository at this point in the history
Update version dependency for zabbix_protocol ruby gem
Update to do testing with Travis CI

Disabling Docker testing for now

TravisCI and JRuby are not playing nice.

Filed a ticket at: travis-ci/travis-rubies#18

Fixes #15
  • Loading branch information
untergeek committed Jun 21, 2016
1 parent 6366ffb commit 33335e3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
---
#sudo: required
sudo: false
jdk: oraclejdk8
env:
- INTEGRATION=false
# - INTEGRATION=true
language: ruby
cache: bundler
cache:
bundler: true
#services:
# - docker
rvm:
- jruby-1.7.23
script:
- bundle exec rspec spec
- jruby-1.7.25
#before_install:
# - docker pull untergeek/logstash_output_zabbix_rspec:latest
# - docker run -i --name="logstash_zabbix_rspec" -t -d -p 10051:10051 untergeek/logstash_output_zabbix_rspec:latest run
script: "./travis-run.sh"
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.0.0
- Breaking: Updated plugin to use new Java Event APIs
- Use zabbix_protocol 0.1.5 or greater (tasty fixes for Zabbix)
- Make TravisCI use JRuby 1.7.25, and have Travis run the unit & integration tests.
# 2.0.2
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
# 2.0.1
Expand All @@ -7,4 +11,4 @@
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
- Dependency on logstash-core update to 2.0
- Update to allow semicolons (or not, e.g. Zabbix 2.0). #6 (davmrtl)
- Update to prevent Logstash from crashing when the Zabbix server becomes unavailable while the plugin is sending data. #9 (dkanbier)
- Update to prevent Logstash from crashing when the Zabbix server becomes unavailable while the plugin is sending data. #9 (dkanbier)
16 changes: 8 additions & 8 deletions lib/logstash/outputs/zabbix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ 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
Expand Down Expand Up @@ -142,10 +142,10 @@ def format_request(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
{
Expand Down Expand Up @@ -183,12 +183,12 @@ def info_check(event, data)
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
Expand Down Expand Up @@ -237,7 +237,7 @@ def send_to_zabbix(event)

public
def receive(event)

return unless field_check(event, @zabbix_host)
send_to_zabbix(event)
end # def event
Expand Down
6 changes: 3 additions & 3 deletions logstash-output-zabbix.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'logstash-output-zabbix'
s.version = '2.0.2'
s.version = '3.0.0'
s.licenses = ["Apache License (2.0)"]
s.summary = "This output sends key/value pairs to a Zabbix server."
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand All @@ -18,8 +18,8 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
s.add_runtime_dependency "zabbix_protocol"
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
s.add_runtime_dependency "zabbix_protocol", ">= 0.1.5"
s.add_runtime_dependency "logstash-codec-plain"
s.add_development_dependency "logstash-devutils", ">= 0.0.12"
s.add_development_dependency "logstash-filter-mutate"
Expand Down
8 changes: 8 additions & 0 deletions travis-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -ex

if [[ "$INTEGRATION" != "true" ]]; then
bundle exec rspec -fd spec
elif [[ "$INTEGRATION" == "true" ]]; then
bundle exec rspec -fd spec -t integration
fi

0 comments on commit 33335e3

Please sign in to comment.