logstash-input-nagioscheck 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +11 -0
- data/README.md +96 -0
- data/lib/logstash/inputs/nagioscheck.rb +128 -0
- data/lib/logstash_registry.rb +4 -0
- data/logstash-input-nagioscheck.gemspec +27 -0
- data/module/elasticsearch/nagios.json +99 -0
- data/module/kibana/6.x/dashboard/Nagios Overview.json +13 -0
- data/module/kibana/6.x/dashboard/nagios.json +1 -0
- data/module/kibana/6.x/index-pattern/nagios.json +5 -0
- data/module/kibana/6.x/visualization/7b67a110-52d9-11e8-8d6e-5ded8718dfbd.json +10 -0
- data/module/kibana/6.x/visualization/d602cb70-52d1-11e8-8d6e-5ded8718dfbd.json +10 -0
- data/module/kibana/6.x/visualization/e1b3e380-52d3-11e8-8d6e-5ded8718dfbd.json +10 -0
- data/module/kibana/6.x/visualization/e6d01410-52d8-11e8-8d6e-5ded8718dfbd.json +10 -0
- data/module/logstash/nagios.conf.erb +10 -0
- data/spec/inputs/nagioscheck_spec.rb +238 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8ca20ad47c778a45985808bcbf33745f7dc0161e60ff62559cc812038437b678
|
4
|
+
data.tar.gz: 704d48106df1f6b9da3bb900f0f9bb89fa54a59d51b61a145080a91fd7183884
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa9abb0d1c8b7b9dff9b6ed822092593646d2c562b6435e879a3af3b6c56c5d36aeabd27427759459a3ab25bff2fb535831d1a94cae84e295caa1eff02ad906e
|
7
|
+
data.tar.gz: c68be11d949439c24c44a2259833cb89120b6892e54d4ff1679700a5d214b6a091f9b4829869b5416e922a93bce7ea460a2a5d6fd4a7dfb91692ad3f8065a0ba
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* - jay.greenberg@elastic.co
|
6
|
+
|
7
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
9
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
10
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Module settings and structure
|
2
|
+
|
3
|
+
## settings
|
4
|
+
|
5
|
+
### logstash.yml
|
6
|
+
|
7
|
+
```
|
8
|
+
modules:
|
9
|
+
- name: netflow
|
10
|
+
var.output.elasticsearch.host: "es.mycloud.com"
|
11
|
+
var.output.elasticsearch.user: "foo"
|
12
|
+
var.output.elasticsearch.password: "password"
|
13
|
+
var.input.tcp.port: 5606
|
14
|
+
```
|
15
|
+
|
16
|
+
### command-line
|
17
|
+
|
18
|
+
```
|
19
|
+
bin/logstash \
|
20
|
+
--modules netflow \
|
21
|
+
-M "netflow.var.output.elasticsearch.host=es.mycloud.com" \
|
22
|
+
-M "netflow.var.output.elasticsearch.user=foo" \
|
23
|
+
-M "netflow.var.output.elasticsearch.password=password" \
|
24
|
+
-M "netflow.var.input.tcp.port=5606"
|
25
|
+
```
|
26
|
+
|
27
|
+
## Current Gem structure
|
28
|
+
```
|
29
|
+
GEM File structure
|
30
|
+
logstash-module-netflow
|
31
|
+
├── configuration
|
32
|
+
│ ├── elasticsearch
|
33
|
+
│ │ └── netflow.json
|
34
|
+
│ ├── kibana
|
35
|
+
│ │ ├── dashboard
|
36
|
+
│ │ │ └── netflow.json (contains '["dash1", "dash2"]')
|
37
|
+
│ │ │ └── dash1.json ("panelJSON" contains refs to visualization panels 1,2 and search 1)
|
38
|
+
│ │ │ └── dash2.json ("panelJSON" contains refs to visualization panel 3 and search 2)
|
39
|
+
│ │ ├── index-pattern
|
40
|
+
| | | └── netflow.json
|
41
|
+
│ │ ├── search
|
42
|
+
| | | └── search1.json
|
43
|
+
| | | └── search2.json
|
44
|
+
│ │ └── vizualization
|
45
|
+
| | | └── panel1.json
|
46
|
+
| | | └── panel2.json
|
47
|
+
| | | └── panel3.json
|
48
|
+
│ └── logstash
|
49
|
+
│ └── netflow.conf.erb
|
50
|
+
├── lib
|
51
|
+
│ └── logstash_registry.rb
|
52
|
+
└── logstash-module-netflow.gemspec
|
53
|
+
```
|
54
|
+
## Proposed multi-version Gem structure
|
55
|
+
```
|
56
|
+
GEM File structure
|
57
|
+
logstash-module-netflow
|
58
|
+
├── configuration
|
59
|
+
│ ├── elasticsearch
|
60
|
+
│ │ └── netflow.json
|
61
|
+
│ ├── kibana
|
62
|
+
│ │ ├── dashboard
|
63
|
+
│ │ │ └── netflow.json (contains '{"v5.5.0": ["dash1", "dash2"], "v6.0.4": ["dash1", "dash2"]')
|
64
|
+
│ │ │ └── v5.5.0
|
65
|
+
│ │ │ | └── dash1.json ("panelJSON" contains refs to visualization panels 1,2 and search 1)
|
66
|
+
│ │ │ | └── dash2.json ("panelJSON" contains refs to visualization panel 3 and search 2)
|
67
|
+
│ │ │ └── v6.0.4
|
68
|
+
│ │ │ └── dash1.json ("panelJSON" contains refs to visualization panels 1,2 and search 1)
|
69
|
+
│ │ │ └── dash2.json ("panelJSON" contains refs to visualization panel 3 and search 2)
|
70
|
+
│ │ ├── index-pattern
|
71
|
+
│ │ │ └── v5
|
72
|
+
| | | | └── netflow.json
|
73
|
+
│ │ │ └── v6
|
74
|
+
| | | └── netflow.json
|
75
|
+
│ │ ├── search
|
76
|
+
│ │ │ └── v5
|
77
|
+
| | | | └── search1.json
|
78
|
+
| | | | └── search2.json
|
79
|
+
│ │ │ └── v6
|
80
|
+
| | | └── search1.json
|
81
|
+
| | | └── search2.json
|
82
|
+
│ │ └── vizualization
|
83
|
+
│ │ │ └── v5
|
84
|
+
| | | | └── panel1.json
|
85
|
+
| | | | └── panel2.json
|
86
|
+
| | | | └── panel3.json
|
87
|
+
│ │ │ └── v6
|
88
|
+
| | | └── panel1.json
|
89
|
+
| | | └── panel2.json
|
90
|
+
| | | └── panel3.json
|
91
|
+
│ └── logstash
|
92
|
+
│ └── netflow.conf.erb
|
93
|
+
├── lib
|
94
|
+
│ └── logstash_registry.rb
|
95
|
+
└── logstash-module-netflow.gemspec
|
96
|
+
```
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/exec"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "stud/interval"
|
5
|
+
require "socket" # for Socket.gethostname
|
6
|
+
require 'securerandom'
|
7
|
+
|
8
|
+
# Generate a repeating message.
|
9
|
+
#
|
10
|
+
# This plugin is intented only as an example.
|
11
|
+
|
12
|
+
class LogStash::Inputs::Nagioscheck < LogStash::Inputs::Exec
|
13
|
+
config_name "nagioscheck"
|
14
|
+
|
15
|
+
# Name of the check
|
16
|
+
config :name, :validate => :string, :required => true
|
17
|
+
|
18
|
+
# Custom parse failure tag
|
19
|
+
config :failure_tag, :validate => :string, :default => "_nagioscheckparsefailure"
|
20
|
+
|
21
|
+
# Override the execute routine from the exec input
|
22
|
+
def execute(queue)
|
23
|
+
start = Time.now
|
24
|
+
output = exit_status = nil
|
25
|
+
begin
|
26
|
+
@logger.debug? && @logger.debug("Running exec", :command => @command)
|
27
|
+
output, exit_status = run_command()
|
28
|
+
rescue StandardError => e
|
29
|
+
@logger.error("Error while running command",
|
30
|
+
:command => @command, :e => e, :backtrace => e.backtrace)
|
31
|
+
rescue Exception => e
|
32
|
+
@logger.error("Exception while running command",
|
33
|
+
:command => @command, :e => e, :backtrace => e.backtrace)
|
34
|
+
end
|
35
|
+
duration = Time.now - start
|
36
|
+
unless exit_status.nil? #exit status will be nil if the command never completed running
|
37
|
+
@logger.debug? && @logger.debug("Command completed", :command => @command, :duration => duration)
|
38
|
+
@codec.decode(output) do |event|
|
39
|
+
decorate(event)
|
40
|
+
|
41
|
+
cmd_message, cmd_perf = event.get("message").split('|')
|
42
|
+
|
43
|
+
event.set("check_uuid", SecureRandom.uuid)
|
44
|
+
|
45
|
+
unless cmd_perf.nil?
|
46
|
+
cmd_perf.strip.split_by_spaces_except_single_quoted.each { |metric|
|
47
|
+
|
48
|
+
results = parse_performance(metric)
|
49
|
+
|
50
|
+
if results.nil?
|
51
|
+
|
52
|
+
@logger.warn("Error parsing nagios performance data (malformed)", :raw => event.get("message"))
|
53
|
+
event.tag(@failure_tag)
|
54
|
+
|
55
|
+
else
|
56
|
+
|
57
|
+
perf_event = event.clone
|
58
|
+
perf_event.remove("message")
|
59
|
+
|
60
|
+
perf_event.set("type", "nagiosmetric")
|
61
|
+
perf_event.set("name", @name)
|
62
|
+
perf_event.set("label", results[1])
|
63
|
+
perf_event.set("uom", results[3])
|
64
|
+
perf_event.set("value", results[2].to_f)
|
65
|
+
perf_event.set("warning", results[4].to_f)
|
66
|
+
perf_event.set("critical", results[5].to_f)
|
67
|
+
perf_event.set("min", results[6].to_f)
|
68
|
+
perf_event.set("max", results[7].to_f)
|
69
|
+
|
70
|
+
queue << perf_event
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
event.set("host", @hostname)
|
78
|
+
event.set("command", @command)
|
79
|
+
event.set("type", "nagioscheck")
|
80
|
+
event.set("message", cmd_message.nil? ? "" : cmd_message.strip)
|
81
|
+
event.set("name", @name)
|
82
|
+
event.set("took_ms", duration * 1000)
|
83
|
+
event.set("status_code", exit_status)
|
84
|
+
event.set("status", nice_status(exit_status))
|
85
|
+
|
86
|
+
queue << event
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
duration
|
91
|
+
end
|
92
|
+
|
93
|
+
end # class LogStash::Inputs::Nagioscheck
|
94
|
+
|
95
|
+
class String
|
96
|
+
def split_by_spaces_except_single_quoted
|
97
|
+
self.split(/\s(?=(?:[^']|'[^']*')*$)/)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def nice_status(status)
|
102
|
+
case status
|
103
|
+
when 0
|
104
|
+
return "OK"
|
105
|
+
when 1
|
106
|
+
return "WARNING"
|
107
|
+
when 2
|
108
|
+
return "CRITICAL"
|
109
|
+
when 3
|
110
|
+
return "UNKNOWN"
|
111
|
+
else
|
112
|
+
return "INVALID STATUS"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
def parse_performance(perf)
|
118
|
+
|
119
|
+
# As per https://github.com/nagios-plugins/nagios-plugin-perl/blob/master/lib/Nagios/Monitoring/Plugin/Performance.pm
|
120
|
+
|
121
|
+
value = /[-+]?[\d\.,]+/
|
122
|
+
value_re = /#{value}(?:e#{value})?/
|
123
|
+
value_with_negative_infinity = /#{value_re}|~/
|
124
|
+
|
125
|
+
regex = /^'?([^'=]+)'?=(#{value_re})([\w%]*);?(#{value_with_negative_infinity}\:?#{value_re}?)?;?(#{value_with_negative_infinity}\:?#{value_re}?)?;?(#{value_re})?;?(#{value_re})?/o
|
126
|
+
regex.match(perf)
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-nagioscheck'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'Logstash NagiosCheck Filter'
|
6
|
+
s.description = 'Parses the output of Nagios Checks (via exec input)'
|
7
|
+
s.homepage = 'http://www.elastic.co'
|
8
|
+
s.authors = ['Jay Greenberg']
|
9
|
+
s.email = 'jay.greenberg@elastic.co'
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = Dir['lib/**/*','module/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
|
+
# Tests
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
|
17
|
+
# Special flag to let us know this is actually a logstash plugin
|
18
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
19
|
+
|
20
|
+
# Gem dependencies
|
21
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
22
|
+
s.add_runtime_dependency 'logstash-codec-plain'
|
23
|
+
s.add_runtime_dependency 'logstash-input-exec', ">= 3.3.0"
|
24
|
+
s.add_runtime_dependency 'stud', '>= 0.0.22'
|
25
|
+
s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
|
26
|
+
s.add_development_dependency 'logstash-input-exec', ">= 3.3.0"
|
27
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
{
|
2
|
+
"mappings": {
|
3
|
+
"doc": {
|
4
|
+
"_meta": {
|
5
|
+
"version": "6.2.0"
|
6
|
+
},
|
7
|
+
"properties": {
|
8
|
+
"@timestamp": {
|
9
|
+
"type": "date"
|
10
|
+
},
|
11
|
+
"@version": {
|
12
|
+
"type": "keyword",
|
13
|
+
"ignore_above": 256
|
14
|
+
},
|
15
|
+
"check_uuid": {
|
16
|
+
"type": "keyword",
|
17
|
+
"ignore_above": 256
|
18
|
+
},
|
19
|
+
"command": {
|
20
|
+
"type": "text",
|
21
|
+
"fields": {
|
22
|
+
"keyword": {
|
23
|
+
"type": "keyword",
|
24
|
+
"ignore_above": 256
|
25
|
+
}
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"critical": {
|
29
|
+
"type": "float"
|
30
|
+
},
|
31
|
+
"host": {
|
32
|
+
"type": "keyword",
|
33
|
+
"ignore_above": 256
|
34
|
+
},
|
35
|
+
"label": {
|
36
|
+
"type": "text",
|
37
|
+
"fields": {
|
38
|
+
"keyword": {
|
39
|
+
"type": "keyword",
|
40
|
+
"ignore_above": 256
|
41
|
+
}
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"max": {
|
45
|
+
"type": "float"
|
46
|
+
},
|
47
|
+
"message": {
|
48
|
+
"type": "text",
|
49
|
+
"fields": {
|
50
|
+
"keyword": {
|
51
|
+
"type": "keyword",
|
52
|
+
"ignore_above": 256
|
53
|
+
}
|
54
|
+
}
|
55
|
+
},
|
56
|
+
"min": {
|
57
|
+
"type": "float"
|
58
|
+
},
|
59
|
+
"name": {
|
60
|
+
"type": "keyword",
|
61
|
+
"ignore_above": 256
|
62
|
+
},
|
63
|
+
"status": {
|
64
|
+
"type": "keyword",
|
65
|
+
"ignore_above": 256
|
66
|
+
},
|
67
|
+
"status_code": {
|
68
|
+
"type": "long"
|
69
|
+
},
|
70
|
+
"tags": {
|
71
|
+
"type": "keyword",
|
72
|
+
"ignore_above": 256
|
73
|
+
},
|
74
|
+
"took_ms": {
|
75
|
+
"type": "float"
|
76
|
+
},
|
77
|
+
"type": {
|
78
|
+
"type": "keyword",
|
79
|
+
"ignore_above": 256
|
80
|
+
},
|
81
|
+
"uom": {
|
82
|
+
"type": "keyword",
|
83
|
+
"ignore_above": 256
|
84
|
+
},
|
85
|
+
"value": {
|
86
|
+
"type": "float"
|
87
|
+
},
|
88
|
+
"warning": {
|
89
|
+
"type": "float"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
},
|
94
|
+
"order": 0,
|
95
|
+
"settings": {
|
96
|
+
"index.refresh_interval": "5s"
|
97
|
+
},
|
98
|
+
"template": "nagios-*"
|
99
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"title": "Nagios Overview",
|
3
|
+
"hits": 0,
|
4
|
+
"description": "",
|
5
|
+
"panelsJSON": "[{\"panelIndex\":\"1\",\"gridData\":{\"x\":3,\"y\":0,\"w\":9,\"h\":3,\"i\":\"1\"},\"id\":\"d602cb70-52d1-11e8-8d6e-5ded8718dfbd\",\"type\":\"visualization\",\"version\":\"6.2.3\"},{\"panelIndex\":\"3\",\"gridData\":{\"x\":6,\"y\":3,\"w\":6,\"h\":3,\"i\":\"3\"},\"embeddableConfig\":{\"table\":{\"sort\":{\"column\":\"7fa9c650-52d3-11e8-a1cd-61c073d732d5\",\"order\":\"desc\"}}},\"id\":\"e1b3e380-52d3-11e8-8d6e-5ded8718dfbd\",\"type\":\"visualization\",\"version\":\"6.2.3\"},{\"panelIndex\":\"5\",\"gridData\":{\"x\":0,\"y\":0,\"w\":3,\"h\":3,\"i\":\"5\"},\"embeddableConfig\":{\"vis\":{\"colors\":{\"Critical\":\"#F29191\",\"OK\":\"#B7DBAB\",\"Warning\":\"#F4D598\"},\"legendOpen\":false}},\"id\":\"e6d01410-52d8-11e8-8d6e-5ded8718dfbd\",\"type\":\"visualization\",\"version\":\"6.2.3\"},{\"panelIndex\":\"6\",\"gridData\":{\"x\":0,\"y\":3,\"w\":6,\"h\":3,\"i\":\"6\"},\"id\":\"7b67a110-52d9-11e8-8d6e-5ded8718dfbd\",\"type\":\"visualization\",\"version\":\"6.2.3\"}]",
|
6
|
+
"optionsJSON": "{\"darkTheme\":false,\"hidePanelTitles\":false,\"useMargins\":true}",
|
7
|
+
"version": 1,
|
8
|
+
"timeRestore": false,
|
9
|
+
"kibanaSavedObjectMeta": {
|
10
|
+
"searchSourceJSON": "{\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[],\"highlightAll\":true,\"version\":true}"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
["Nagios Overview"]
|
@@ -0,0 +1,5 @@
|
|
1
|
+
{
|
2
|
+
"title": "nagios-*",
|
3
|
+
"timeFieldName": "@timestamp",
|
4
|
+
"fields": "[{\"name\":\"@timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"@version\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"searchable\":false,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":false},{\"name\":\"check_uuid\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"command\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"command.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"critical\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"label\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"label.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"max\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"message\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"name\":\"message.keyword\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"min\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"status\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"status_code\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"tags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"took_ms\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"uom\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"value\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"warning\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]"
|
5
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"title": "Status Overview By Host",
|
3
|
+
"visState": "{\"title\":\"Status Overview By Host\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"table\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"filters\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"count\",\"field\":\"name\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"bar\",\"line_width\":\"0\",\"point_size\":1,\"fill\":\"0.5\",\"stacked\":\"stacked\",\"terms_field\":\"label.keyword\",\"label\":\"OK\",\"filter\":\"status:OK\",\"split_filters\":[{\"filter\":\"status: OK\",\"label\":\"OK\",\"color\":\"#68BC00\",\"id\":\"b6262af0-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: WARNING\",\"label\":\"WARNING\",\"color\":\"rgba(252,220,0,1)\",\"id\":\"b9c91b40-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: CRITICAL\",\"label\":\"CRITICAL\",\"color\":\"rgba(244,78,59,1)\",\"id\":\"c95387d0-52d0-11e8-a1cd-61c073d732d5\"}],\"split_color_mode\":\"gradient\",\"hide_in_legend\":0,\"color_rules\":[{\"value\":0,\"id\":\"7eae92e0-52d2-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(52,199,64,1)\",\"opperator\":\"gt\"}],\"offset_time\":\"\",\"value_template\":\"\"},{\"id\":\"50dd0800-52d3-11e8-a1cd-61c073d732d5\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"50dd0801-52d3-11e8-a1cd-61c073d732d5\",\"type\":\"count\",\"field\":\"name\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"label\":\"WARNING\",\"color_rules\":[{\"value\":0,\"id\":\"702721f0-52d3-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(236,214,44,1)\",\"opperator\":\"gt\"}],\"filter\":\"status:WARNING\",\"offset_time\":\"\",\"value_template\":\"\"},{\"id\":\"7fa9c650-52d3-11e8-a1cd-61c073d732d5\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"7fa9c651-52d3-11e8-a1cd-61c073d732d5\",\"type\":\"count\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"label\":\"CRITICAL\",\"color_rules\":[{\"value\":0,\"id\":\"9c22bee0-52d3-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(255,2,16,1)\",\"opperator\":\"gt\"}],\"filter\":\"status:CRITICAL\",\"offset_time\":\"\",\"value_template\":\"\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"nagios*\",\"interval\":\"10m\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":0,\"gauge_color_rules\":[{\"id\":\"6bbfd790-52d0-11e8-a1cd-61c073d732d5\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"bar_color_rules\":[{\"id\":\"42bc8120-52d2-11e8-a1cd-61c073d732d5\"}],\"background_color_rules\":[{\"id\":\"4d7a4a70-52d2-11e8-a1cd-61c073d732d5\"}],\"pivot_id\":\"host\",\"pivot_label\":\"Status in the Last 10 Minutes\",\"markdown\":\"{{warning.last.raw}}\",\"pivot_rows\":\"100\",\"drop_last_bucket\":0},\"aggs\":[]}",
|
4
|
+
"uiStateJSON": "{}",
|
5
|
+
"description": "",
|
6
|
+
"version": 1,
|
7
|
+
"kibanaSavedObjectMeta": {
|
8
|
+
"searchSourceJSON": "{}"
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"title": "Status Overview",
|
3
|
+
"visState": "{\"title\":\"Status Overview\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"timeseries\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"filters\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"cardinality\",\"field\":\"name\"},{\"id\":\"ee99b260-52d2-11e8-a1cd-61c073d732d5\",\"type\":\"count\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"bar\",\"line_width\":\"0\",\"point_size\":1,\"fill\":\"0.5\",\"stacked\":\"stacked\",\"terms_field\":\"label.keyword\",\"label\":\"OK\",\"filter\":\"\",\"split_filters\":[{\"filter\":\"status: OK\",\"label\":\"OK\",\"color\":\"#68BC00\",\"id\":\"b6262af0-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: WARNING\",\"label\":\"WARNING\",\"color\":\"rgba(252,220,0,1)\",\"id\":\"b9c91b40-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: CRITICAL\",\"label\":\"CRITICAL\",\"color\":\"rgba(244,78,59,1)\",\"id\":\"c95387d0-52d0-11e8-a1cd-61c073d732d5\"}],\"split_color_mode\":\"gradient\",\"hide_in_legend\":0,\"color_rules\":[{\"id\":\"7eae92e0-52d2-11e8-a1cd-61c073d732d5\"}]}],\"time_field\":\"@timestamp\",\"index_pattern\":\"nagios*\",\"interval\":\"\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":0,\"gauge_color_rules\":[{\"id\":\"6bbfd790-52d0-11e8-a1cd-61c073d732d5\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"bar_color_rules\":[{\"id\":\"42bc8120-52d2-11e8-a1cd-61c073d732d5\"}],\"background_color_rules\":[{\"id\":\"4d7a4a70-52d2-11e8-a1cd-61c073d732d5\"}],\"pivot_id\":\"name\",\"pivot_label\":\"Name\",\"markdown\":\"{{warning.last.raw}}\"},\"aggs\":[]}",
|
4
|
+
"uiStateJSON": "{}",
|
5
|
+
"description": "",
|
6
|
+
"version": 1,
|
7
|
+
"kibanaSavedObjectMeta": {
|
8
|
+
"searchSourceJSON": "{}"
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"title": "Status Overview By Service",
|
3
|
+
"visState": "{\"title\":\"Status Overview By Service\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"table\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"#68BC00\",\"split_mode\":\"filters\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"count\",\"field\":\"name\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"bar\",\"line_width\":\"0\",\"point_size\":1,\"fill\":\"0.5\",\"stacked\":\"stacked\",\"terms_field\":\"label.keyword\",\"label\":\"OK\",\"filter\":\"status:OK\",\"split_filters\":[{\"filter\":\"status: OK\",\"label\":\"OK\",\"color\":\"#68BC00\",\"id\":\"b6262af0-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: WARNING\",\"label\":\"WARNING\",\"color\":\"rgba(252,220,0,1)\",\"id\":\"b9c91b40-52d0-11e8-a1cd-61c073d732d5\"},{\"filter\":\"status: CRITICAL\",\"label\":\"CRITICAL\",\"color\":\"rgba(244,78,59,1)\",\"id\":\"c95387d0-52d0-11e8-a1cd-61c073d732d5\"}],\"split_color_mode\":\"gradient\",\"hide_in_legend\":0,\"color_rules\":[{\"value\":0,\"id\":\"7eae92e0-52d2-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(52,199,64,1)\",\"opperator\":\"gt\"}],\"offset_time\":\"\",\"value_template\":\"\"},{\"id\":\"50dd0800-52d3-11e8-a1cd-61c073d732d5\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"50dd0801-52d3-11e8-a1cd-61c073d732d5\",\"type\":\"count\",\"field\":\"name\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"label\":\"WARNING\",\"color_rules\":[{\"value\":0,\"id\":\"702721f0-52d3-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(236,214,44,1)\",\"opperator\":\"gt\"}],\"filter\":\"status:WARNING\",\"offset_time\":\"\",\"value_template\":\"\"},{\"id\":\"7fa9c650-52d3-11e8-a1cd-61c073d732d5\",\"color\":\"#68BC00\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"7fa9c651-52d3-11e8-a1cd-61c073d732d5\",\"type\":\"count\"}],\"seperate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"label\":\"CRITICAL\",\"color_rules\":[{\"value\":0,\"id\":\"9c22bee0-52d3-11e8-a1cd-61c073d732d5\",\"text\":\"rgba(255,2,16,1)\",\"opperator\":\"gt\"}],\"filter\":\"status:CRITICAL\",\"offset_time\":\"\",\"value_template\":\"\"}],\"time_field\":\"@timestamp\",\"index_pattern\":\"nagios*\",\"interval\":\"10m\",\"axis_position\":\"left\",\"axis_formatter\":\"number\",\"show_legend\":1,\"show_grid\":0,\"gauge_color_rules\":[{\"id\":\"6bbfd790-52d0-11e8-a1cd-61c073d732d5\"}],\"gauge_width\":10,\"gauge_inner_width\":10,\"gauge_style\":\"half\",\"bar_color_rules\":[{\"id\":\"42bc8120-52d2-11e8-a1cd-61c073d732d5\"}],\"background_color_rules\":[{\"id\":\"4d7a4a70-52d2-11e8-a1cd-61c073d732d5\"}],\"pivot_id\":\"name\",\"pivot_label\":\"Status in the Last 10 Minutes\",\"markdown\":\"{{warning.last.raw}}\",\"pivot_rows\":\"100\",\"drop_last_bucket\":0},\"aggs\":[]}",
|
4
|
+
"uiStateJSON": "{}",
|
5
|
+
"description": "",
|
6
|
+
"version": 1,
|
7
|
+
"kibanaSavedObjectMeta": {
|
8
|
+
"searchSourceJSON": "{}"
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"title": "Status of All Hosts",
|
3
|
+
"visState": "{\"title\":\"Status of All Hosts\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":false,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"host\",\"customLabel\":\"Hosts\"}},{\"id\":\"2\",\"enabled\":true,\"type\":\"filters\",\"schema\":\"segment\",\"params\":{\"filters\":[{\"input\":{\"query\":\"status:OK\"},\"label\":\"OK\"},{\"input\":{\"query\":\"status:CRITICAL\"},\"label\":\"Critical\"},{\"input\":{\"query\":\"status:WARNING\"},\"label\":\"Warning\"}]}}]}",
|
4
|
+
"uiStateJSON": "{\"vis\":{\"colors\":{\"Critical\":\"#F29191\",\"OK\":\"#B7DBAB\",\"Warning\":\"#F4D598\"}}}",
|
5
|
+
"description": "",
|
6
|
+
"version": 1,
|
7
|
+
"kibanaSavedObjectMeta": {
|
8
|
+
"searchSourceJSON": "{\"index\":\"nagios-*\",\"filter\":[],\"query\":{\"query\":\"\",\"language\":\"lucene\"}}"
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/inputs/nagioscheck"
|
4
|
+
|
5
|
+
|
6
|
+
describe LogStash::Inputs::Nagioscheck do
|
7
|
+
|
8
|
+
it_behaves_like "an interruptible input plugin" do
|
9
|
+
let(:config) { { "name" => "my_load_check", "command" => "/usr/local/sbin/check_load -w 1,2,3 -c 4,5,6", "interval" => 100 } }
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
context "when we simulate certain output 1" do
|
14
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_load_check", "command" => "echo 'Everything OK | load1=0.010;5.000;9.000;0; load5=0.060;5.000;9.000;0; load15=2.010;5.000;9.000;0;'", "interval" => 0) }
|
15
|
+
let(:queue) { [] }
|
16
|
+
|
17
|
+
before do
|
18
|
+
input.register
|
19
|
+
input.execute(queue)
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
input.stop
|
24
|
+
end
|
25
|
+
|
26
|
+
it "it parses out properly" do
|
27
|
+
expect(queue.length).to eq 4
|
28
|
+
|
29
|
+
expect(queue[0].get("value")).to eq 0.01
|
30
|
+
|
31
|
+
expect(queue[1].get("value")).to eq 0.06
|
32
|
+
expect(queue[1].get("label")).to eq "load5"
|
33
|
+
|
34
|
+
expect(queue[2].get("value")).to eq 2.01
|
35
|
+
|
36
|
+
expect(queue[3].get("message")).to eq "Everything OK"
|
37
|
+
expect(queue[3].get("status")).to eq "OK"
|
38
|
+
expect(queue[3].get("took_ms")).to be > 0
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when we simulate certain output 2" do
|
45
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_check", "command" => "echo 'Everything OK | users=4;20;50;0'", "interval" => 0) }
|
46
|
+
let(:queue) { [] }
|
47
|
+
|
48
|
+
before do
|
49
|
+
input.register
|
50
|
+
input.execute(queue)
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
input.stop
|
55
|
+
end
|
56
|
+
|
57
|
+
it "it parses out properly" do
|
58
|
+
|
59
|
+
expect(queue.length).to eq 2
|
60
|
+
|
61
|
+
expect(queue[0].get("value")).to eq 4
|
62
|
+
expect(queue[0].get("warning")).to eq 20
|
63
|
+
expect(queue[0].get("critical")).to eq 50
|
64
|
+
expect(queue[0].get("min")).to eq 0
|
65
|
+
|
66
|
+
expect(queue[1].get("message")).to eq "Everything OK"
|
67
|
+
expect(queue[1].get("status")).to eq "OK"
|
68
|
+
expect(queue[1].get("took_ms")).to be > 0
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
context "when we simulate certain output 3 - quoted strings" do
|
78
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_check", "command" => "echo 'Some Disk Data | /home/a-m=0;0;0 '\"'\"'i have spaces'\"'\"'=20 '\"'\"'12345678901234567890'\"'\"'=20'", "interval" => 0) }
|
79
|
+
let(:queue) { [] }
|
80
|
+
|
81
|
+
before do
|
82
|
+
input.register
|
83
|
+
input.execute(queue)
|
84
|
+
end
|
85
|
+
|
86
|
+
after do
|
87
|
+
input.stop
|
88
|
+
end
|
89
|
+
|
90
|
+
it "it parses out properly" do
|
91
|
+
|
92
|
+
expect(queue.length).to eq 4
|
93
|
+
|
94
|
+
expect(queue[0].get("label")).to eq "/home/a-m"
|
95
|
+
expect(queue[0].get("value")).to eq 0
|
96
|
+
expect(queue[0].get("warning")).to eq 0
|
97
|
+
expect(queue[0].get("critical")).to eq 0
|
98
|
+
expect(queue[1].get("label")).to eq "i have spaces"
|
99
|
+
expect(queue[1].get("value")).to eq 20
|
100
|
+
expect(queue[2].get("label")).to eq "12345678901234567890"
|
101
|
+
expect(queue[2].get("value")).to eq 20
|
102
|
+
|
103
|
+
expect(queue[3].get("status")).to eq "OK"
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when we simulate certain output 4" do
|
110
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_uom_check", "command" => "echo 'Some Float Parsing with Uom | time=0.002722s;0.000000;0.000000;0.000000;10.000000'", "interval" => 0) }
|
111
|
+
let(:queue) { [] }
|
112
|
+
|
113
|
+
before do
|
114
|
+
input.register
|
115
|
+
input.execute(queue)
|
116
|
+
end
|
117
|
+
|
118
|
+
after do
|
119
|
+
input.stop
|
120
|
+
end
|
121
|
+
|
122
|
+
it "it parses out properly" do
|
123
|
+
|
124
|
+
expect(queue.length).to eq 2
|
125
|
+
|
126
|
+
expect(queue[0].get("label")).to eq "time"
|
127
|
+
expect(queue[0].get("value")).to eq 0.002722
|
128
|
+
expect(queue[0].get("uom")).to eq "s"
|
129
|
+
expect(queue[0].get("max")).to eq 10
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
context "when we simulate malformed output" do
|
137
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_broken_plugin", "failure_tag" => "i_must_appear", "command" => "echo 'Some Status | invalid;perf data'", "interval" => 0) }
|
138
|
+
let(:queue) { [] }
|
139
|
+
|
140
|
+
before do
|
141
|
+
input.register
|
142
|
+
input.execute(queue)
|
143
|
+
end
|
144
|
+
|
145
|
+
after do
|
146
|
+
input.stop
|
147
|
+
end
|
148
|
+
|
149
|
+
it "it tags with parse failure" do
|
150
|
+
expect(queue[0].get("tags")).to include("i_must_appear")
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
context "when we have a string in the perf data" do
|
156
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_broken_plugin", "failure_tag" => "i_must_appear", "command" => "echo 'String in perf data is parsed as 0| time=0.002722s;0.000000;string;0.000000;10.000000'", "interval" => 0) }
|
157
|
+
let(:queue) { [] }
|
158
|
+
|
159
|
+
before do
|
160
|
+
input.register
|
161
|
+
input.execute(queue)
|
162
|
+
end
|
163
|
+
|
164
|
+
after do
|
165
|
+
input.stop
|
166
|
+
end
|
167
|
+
|
168
|
+
it "it parses it as 0" do
|
169
|
+
expect(queue[0].get("critical")).to eq 0
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
context "when we have empty output" do
|
176
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_broken_plugin", "failure_tag" => "i_must_appear", "command" => "echo ''", "interval" => 0) }
|
177
|
+
let(:queue) { [] }
|
178
|
+
|
179
|
+
before do
|
180
|
+
input.register
|
181
|
+
input.execute(queue)
|
182
|
+
end
|
183
|
+
|
184
|
+
after do
|
185
|
+
input.stop
|
186
|
+
end
|
187
|
+
|
188
|
+
it "it's ignored" do
|
189
|
+
expect(queue[0].get("status")).to eq "OK"
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
context "when a real check runs" do
|
195
|
+
let(:input) { LogStash::Plugin.lookup("input", "nagioscheck").new("name" => "my_load_check", "command" => "/usr/local/sbin/check_load -w 0,2,3 -c 0,5,6", "interval" => 0) }
|
196
|
+
let(:queue) { [] }
|
197
|
+
|
198
|
+
before do
|
199
|
+
input.register
|
200
|
+
input.execute(queue)
|
201
|
+
end
|
202
|
+
|
203
|
+
after do
|
204
|
+
input.stop
|
205
|
+
end
|
206
|
+
|
207
|
+
it "it parses out properly" do
|
208
|
+
|
209
|
+
expect(queue[0].get('type')).to eq "nagiosmetric"
|
210
|
+
expect(queue[0].get('name')).to eq "my_load_check"
|
211
|
+
expect(queue[0].get('label')).to eq "load1"
|
212
|
+
expect(queue[0].get('warning')).to eq 0
|
213
|
+
expect(queue[0].get('critical')).to eq 0
|
214
|
+
expect(queue[0].get('min')).to eq 0
|
215
|
+
|
216
|
+
expect(queue[1].get('label')).to eq "load5"
|
217
|
+
expect(queue[1].get('warning')).to eq 2
|
218
|
+
expect(queue[1].get('critical')).to eq 5
|
219
|
+
expect(queue[1].get('min')).to eq 0
|
220
|
+
|
221
|
+
expect(queue[2].get('label')).to eq "load15"
|
222
|
+
expect(queue[2].get('warning')).to eq 3
|
223
|
+
expect(queue[2].get('critical')).to eq 6
|
224
|
+
expect(queue[2].get('min')).to eq 0
|
225
|
+
|
226
|
+
expect(queue[3].get('message')).not_to be_nil
|
227
|
+
expect(queue[3].get('message')).to include("load average")
|
228
|
+
expect(queue[3].get('status')).to eq "CRITICAL"
|
229
|
+
expect(queue[3].get('name')).to eq "my_load_check"
|
230
|
+
expect(queue[3].get('took_ms')).to be > 0
|
231
|
+
expect(queue[3].get('type')).to eq "nagioscheck"
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-nagioscheck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jay Greenberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '2.0'
|
19
|
+
name: logstash-core-plugin-api
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: logstash-codec-plain
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.3.0
|
47
|
+
name: logstash-input-exec
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.0.22
|
61
|
+
name: stud
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.22
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.0.16
|
75
|
+
name: logstash-devutils
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.16
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 3.3.0
|
89
|
+
name: logstash-input-exec
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.3.0
|
97
|
+
description: Parses the output of Nagios Checks (via exec input)
|
98
|
+
email: jay.greenberg@elastic.co
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- CHANGELOG.md
|
104
|
+
- CONTRIBUTORS
|
105
|
+
- DEVELOPER.md
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- lib/logstash/inputs/nagioscheck.rb
|
110
|
+
- lib/logstash_registry.rb
|
111
|
+
- logstash-input-nagioscheck.gemspec
|
112
|
+
- module/elasticsearch/nagios.json
|
113
|
+
- module/kibana/6.x/dashboard/Nagios Overview.json
|
114
|
+
- module/kibana/6.x/dashboard/nagios.json
|
115
|
+
- module/kibana/6.x/index-pattern/nagios.json
|
116
|
+
- module/kibana/6.x/visualization/7b67a110-52d9-11e8-8d6e-5ded8718dfbd.json
|
117
|
+
- module/kibana/6.x/visualization/d602cb70-52d1-11e8-8d6e-5ded8718dfbd.json
|
118
|
+
- module/kibana/6.x/visualization/e1b3e380-52d3-11e8-8d6e-5ded8718dfbd.json
|
119
|
+
- module/kibana/6.x/visualization/e6d01410-52d8-11e8-8d6e-5ded8718dfbd.json
|
120
|
+
- module/logstash/nagios.conf.erb
|
121
|
+
- spec/inputs/nagioscheck_spec.rb
|
122
|
+
homepage: http://www.elastic.co
|
123
|
+
licenses:
|
124
|
+
- Apache-2.0
|
125
|
+
metadata:
|
126
|
+
logstash_plugin: 'true'
|
127
|
+
logstash_group: input
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.6.13
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Logstash NagiosCheck Filter
|
148
|
+
test_files:
|
149
|
+
- spec/inputs/nagioscheck_spec.rb
|