logstash-output-nagios 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 +4 -0
- data/README.md +4 -4
- data/lib/logstash/outputs/nagios.rb +16 -8
- data/logstash-output-nagios.gemspec +3 -2
- data/spec/outputs/nagios_spec.rb +27 -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: d4490e2d4923050abf96853ccb696d81a5c2250a
|
4
|
+
data.tar.gz: 6b8d9bb9f32987cc10b2e29dd51ad38c0eb848b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87249592f9987856ead51d22337ecf4e750efcbb8889d462b149ef507111744d89145460a3ab823caccfb03ff2263fd2c44e4ea05f34f94c339c3564b02a10fe
|
7
|
+
data.tar.gz: 104f46387eb144c9683f4fc351f1067e0b8d106daaef739cb7d181c28094438f6988429da131407f9541fe414a3048a51700d5c949425788dc10ccfb48392172
|
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.
|
@@ -36,22 +36,20 @@ class LogStash::Outputs::Nagios < LogStash::Outputs::Base
|
|
36
36
|
config_name "nagios"
|
37
37
|
|
38
38
|
# The full path to your Nagios command file.
|
39
|
-
config :commandfile, :
|
39
|
+
config :commandfile, :default => "/var/lib/nagios3/rw/nagios.cmd"
|
40
40
|
|
41
41
|
# The Nagios check level. Should be one of 0=OK, 1=WARNING, 2=CRITICAL,
|
42
42
|
# 3=UNKNOWN. Defaults to 2 - CRITICAL.
|
43
43
|
config :nagios_level, :validate => [ "0", "1", "2", "3" ], :default => "2"
|
44
44
|
|
45
|
-
public
|
46
45
|
def register
|
47
46
|
# nothing to do
|
48
47
|
end # def register
|
49
48
|
|
50
|
-
public
|
51
49
|
def receive(event)
|
52
50
|
return unless output?(event)
|
53
51
|
|
54
|
-
if !
|
52
|
+
if !command_file_exist?
|
55
53
|
@logger.warn("Skipping nagios output; command file is missing",
|
56
54
|
:commandfile => @commandfile, :missed_event => event)
|
57
55
|
return
|
@@ -105,14 +103,24 @@ class LogStash::Outputs::Nagios < LogStash::Outputs::Base
|
|
105
103
|
@logger.debug("Opening nagios command file", :commandfile => @commandfile,
|
106
104
|
:nagios_command => cmd)
|
107
105
|
begin
|
108
|
-
|
109
|
-
f.puts(cmd)
|
110
|
-
f.flush # TODO(sissel): probably don't need this.
|
111
|
-
end
|
106
|
+
send_to_nagios(cmd)
|
112
107
|
rescue => e
|
113
108
|
@logger.warn("Skipping nagios output; error writing to command file",
|
114
109
|
:commandfile => @commandfile, :missed_event => event,
|
115
110
|
:exception => e, :backtrace => e.backtrace)
|
116
111
|
end
|
117
112
|
end # def receive
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def command_file_exist?
|
117
|
+
File.exists?(@commandfile)
|
118
|
+
end
|
119
|
+
|
120
|
+
def send_to_nagios(cmd)
|
121
|
+
File.open(@commandfile, "r+") do |f|
|
122
|
+
f.puts(cmd)
|
123
|
+
f.flush # TODO(sissel): probably don't need this.
|
124
|
+
end
|
125
|
+
end
|
118
126
|
end # class LogStash::Outputs::Nagios
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-nagios'
|
4
|
-
s.version = '1.
|
4
|
+
s.version = '1.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "The Nagios output is used for sending passive check results to Nagios via the Nagios command file"
|
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
|
data/spec/outputs/nagios_spec.rb
CHANGED
@@ -1 +1,27 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative "../spec_helper"
|
3
|
+
|
4
|
+
describe LogStash::Outputs::Nagios do
|
5
|
+
|
6
|
+
it "should register without errors" do
|
7
|
+
plugin = LogStash::Plugin.lookup("output", "nagios").new
|
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_service" => "nagios_service", "nagios_host" => "nagios_host" } }
|
14
|
+
let(:event) { LogStash::Event.new(properties) }
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
subject.register
|
18
|
+
expect(subject).to receive(:command_file_exist?).and_return(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "send the event to nagios" do
|
22
|
+
expect(subject).to receive(:send_to_nagios)
|
23
|
+
subject.receive(event)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
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
|
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.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/outputs/nagios_spec.rb
|
70
|
+
- logstash-output-nagios.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.rb
|
62
|
-
- logstash-output-nagios.gemspec
|
63
|
-
- spec/outputs/nagios_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: The Nagios output is used for sending passive check results to Nagios via the Nagios command file
|
90
103
|
test_files:
|
104
|
+
- spec/spec_helper.rb
|
91
105
|
- spec/outputs/nagios_spec.rb
|
data/.gitignore
DELETED