logstash-output-nagios_nsca 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +4 -4
- data/lib/logstash/outputs/nagios_nsca.rb +15 -6
- data/logstash-output-nagios_nsca.gemspec +3 -2
- data/spec/outputs/nagios_nsca_spec.rb +30 -1
- data/spec/spec_helper.rb +3 -0
- metadata +23 -9
- data/.gitignore +0 -4
- data/Rakefile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33d03b1698c4939671b35cc1978d3918d3fedd7
|
4
|
+
data.tar.gz: a2a7677936f9571d4832c4c1a9b88af273833c55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403099038c1ba193b0165258bb795a7bd2fc7e8b63a964bf4fd974f6b77a0bf702c1c85ccc0d55a8a791d1d6a0090602db87e611ce90aaed3683cac0e986573b
|
7
|
+
data.tar.gz: 7d47667b95fab12bd935c1a32e629adfcadde83c6ffb823b0d62c3cd3b582647be55949fd426e9d36730706d8e0ec67ca1f464109586f9f7512ceb280dcdcf82
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
5
|
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
9
|
-
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
10
10
|
|
11
11
|
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
-
- For more asciidoc formatting tips, see the excellent reference here https://github.com/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -37,7 +37,7 @@ class LogStash::Outputs::NagiosNsca < LogStash::Outputs::Base
|
|
37
37
|
config :port, :validate => :number, :default => 5667
|
38
38
|
|
39
39
|
# The path to the 'send_nsca' binary on the local host.
|
40
|
-
config :send_nsca_bin, :validate => :
|
40
|
+
config :send_nsca_bin, :validate => :string, :default => "/usr/sbin/send_nsca"
|
41
41
|
|
42
42
|
# The path to the send_nsca config file on the local host.
|
43
43
|
# Leave blank if you don't want to provide a config file.
|
@@ -75,7 +75,7 @@ class LogStash::Outputs::NagiosNsca < LogStash::Outputs::Base
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# skip if 'send_nsca' binary doesn't exist
|
78
|
-
if !
|
78
|
+
if !command_file_exist?
|
79
79
|
@logger.warn("Skipping nagios_nsca output; send_nsca_bin file is missing",
|
80
80
|
"send_nsca_bin" => @send_nsca_bin, "missed_event" => event)
|
81
81
|
return
|
@@ -114,10 +114,7 @@ class LogStash::Outputs::NagiosNsca < LogStash::Outputs::Base
|
|
114
114
|
@logger.debug("Running send_nsca command", :nagios_nsca_command => cmd.join(" "), :message => message)
|
115
115
|
|
116
116
|
begin
|
117
|
-
|
118
|
-
i.puts(message)
|
119
|
-
i.close
|
120
|
-
end
|
117
|
+
send_to_nagios(cmd)
|
121
118
|
rescue => e
|
122
119
|
@logger.warn(
|
123
120
|
"Skipping nagios_nsca output; error calling send_nsca",
|
@@ -129,4 +126,16 @@ class LogStash::Outputs::NagiosNsca < LogStash::Outputs::Base
|
|
129
126
|
@logger.debug("Backtrace", :backtrace => e.backtrace)
|
130
127
|
end
|
131
128
|
end # def receive
|
129
|
+
|
130
|
+
def command_file_exist?
|
131
|
+
File.exists?(@send_nsca_bin)
|
132
|
+
end
|
133
|
+
|
134
|
+
def send_to_nagios(cmd)
|
135
|
+
Open3.popen3(*cmd) do |i, o, e|
|
136
|
+
i.puts(message)
|
137
|
+
i.close
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
132
141
|
end # class LogStash::Outputs::NagiosNsca
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-nagios_nsca'
|
4
|
-
s.version = '1.
|
4
|
+
s.version = '1.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output is used for sending passive check results to Nagios through the NSCA protocol."
|
7
7
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
14
|
-
s.files =
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
15
|
|
16
16
|
# Tests
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
23
|
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
24
|
+
s.add_runtime_dependency "logstash-codec-plain"
|
24
25
|
|
25
26
|
s.add_development_dependency 'logstash-devutils'
|
26
27
|
end
|
@@ -1 +1,30 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative "../spec_helper"
|
3
|
+
|
4
|
+
describe LogStash::Outputs::NagiosNsca do
|
5
|
+
|
6
|
+
it "should register without errors" do
|
7
|
+
plugin = LogStash::Plugin.lookup("output", "nagios_nsca").new({"nagios_status" => "1"})
|
8
|
+
expect { plugin.register }.to_not raise_error
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "send" do
|
12
|
+
|
13
|
+
let(:properties) { { "message" => "This is a message!", "nagios_status" => "nagios_status" } }
|
14
|
+
let(:event) { LogStash::Event.new(properties) }
|
15
|
+
|
16
|
+
|
17
|
+
subject { LogStash::Outputs::NagiosNsca.new({ "nagios_status" => "1" }) }
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
subject.register
|
21
|
+
expect(subject).to receive(:command_file_exist?).and_return(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "send the event to nagios" do
|
25
|
+
expect(subject).to receive(:send_to_nagios)
|
26
|
+
subject.receive(event)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-nagios_nsca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
version: 2.0.0
|
31
31
|
prerelease: false
|
32
32
|
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-codec-plain
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: logstash-devutils
|
35
49
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -50,17 +64,16 @@ executables: []
|
|
50
64
|
extensions: []
|
51
65
|
extra_rdoc_files: []
|
52
66
|
files:
|
53
|
-
- .
|
67
|
+
- lib/logstash/outputs/nagios_nsca.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/outputs/nagios_nsca_spec.rb
|
70
|
+
- logstash-output-nagios_nsca.gemspec
|
71
|
+
- README.md
|
54
72
|
- CHANGELOG.md
|
55
73
|
- CONTRIBUTORS
|
56
74
|
- Gemfile
|
57
75
|
- LICENSE
|
58
76
|
- NOTICE.TXT
|
59
|
-
- README.md
|
60
|
-
- Rakefile
|
61
|
-
- lib/logstash/outputs/nagios_nsca.rb
|
62
|
-
- logstash-output-nagios_nsca.gemspec
|
63
|
-
- spec/outputs/nagios_nsca_spec.rb
|
64
77
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
65
78
|
licenses:
|
66
79
|
- Apache License (2.0)
|
@@ -83,9 +96,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
96
|
version: '0'
|
84
97
|
requirements: []
|
85
98
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.1.9
|
87
100
|
signing_key:
|
88
101
|
specification_version: 4
|
89
102
|
summary: This output is used for sending passive check results to Nagios through the NSCA protocol.
|
90
103
|
test_files:
|
104
|
+
- spec/spec_helper.rb
|
91
105
|
- spec/outputs/nagios_nsca_spec.rb
|
data/.gitignore
DELETED