sensu-plugins-edgelab 1.10.3 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/check-logstash-pipeline.rb +144 -0
- data/bin/check-rabbitmq-queues-synchronised.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65bffec0812ae4c22e5d344085da0eadfa107f0f
|
4
|
+
data.tar.gz: 146ff01074cfe98675c1c956e6127b2d256e6573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b60a1b64c359ae8943ba0b3d9f4934dbf35eca0da752192e96d3d293655acd0a00dcd240eb2da123b9aacf527839b94f0e53a0e53f3aa8f103a5c61407a1f4
|
7
|
+
data.tar.gz: 8971788448f2961564ff9187909fd67e82372602d3c81e453689633679e8e29254b6ef17939ee2234942e6fbb92b19da74ee393142fc8537d06b084ffc521ab5
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Check Logstash pipeline to Elasticsearch
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
# DESCRIPTION:
|
7
|
+
# This plugin sends a message to Logstash and check if it arrives correctly in
|
8
|
+
# Elasticsearch.
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
# gem: rest-client
|
16
|
+
#
|
17
|
+
# LICENSE:
|
18
|
+
# Copyright 2017 Jonathan Ballet <jballet@edgelab.ch>
|
19
|
+
#
|
20
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
21
|
+
# for details.
|
22
|
+
|
23
|
+
require 'sensu-plugin/check/cli'
|
24
|
+
require 'rest-client'
|
25
|
+
|
26
|
+
require 'digest'
|
27
|
+
require 'json'
|
28
|
+
require 'socket'
|
29
|
+
require 'time'
|
30
|
+
require 'timeout'
|
31
|
+
|
32
|
+
class CheckLogstashPipeline < Sensu::Plugin::Check::CLI
|
33
|
+
option :duration_warning,
|
34
|
+
description: 'Warn if lookup time greater than TIME',
|
35
|
+
short: '-w TIME',
|
36
|
+
long: '--warning TIME',
|
37
|
+
proc: proc(&:to_i),
|
38
|
+
default: 15
|
39
|
+
|
40
|
+
option :duration_critical,
|
41
|
+
description: 'Error if lookup time greater than TIME',
|
42
|
+
short: '-c TIME',
|
43
|
+
long: '--critical TIME',
|
44
|
+
proc: proc(&:to_i),
|
45
|
+
default: 40
|
46
|
+
|
47
|
+
option :logstash_host,
|
48
|
+
description: 'Logstash hostname',
|
49
|
+
long: '--logstash-host HOSTNAME',
|
50
|
+
default: 'json-tcp.logstash.service.consul'
|
51
|
+
|
52
|
+
option :logstash_port,
|
53
|
+
description: 'Logstash TCP port',
|
54
|
+
long: '--logstash-port PORTT',
|
55
|
+
proc: proc(&:to_i),
|
56
|
+
default: 10_515
|
57
|
+
|
58
|
+
option :elasticsearch_url,
|
59
|
+
description: 'Elasticsearch URL',
|
60
|
+
long: '--elasticsearch URL',
|
61
|
+
default: 'http://elasticsearch.service.consul:9200'
|
62
|
+
|
63
|
+
option :timeout,
|
64
|
+
description: 'Timeout waiting for the event to show up in Elasticsearch',
|
65
|
+
short: '-t TIME',
|
66
|
+
long: '--timeout TIME',
|
67
|
+
proc: proc(&:to_i),
|
68
|
+
default: 60
|
69
|
+
|
70
|
+
option :elaticsearch_request_interval,
|
71
|
+
description: 'Duration to wait between each Elasticsearch request',
|
72
|
+
short: '-i TIME',
|
73
|
+
long: '--interval TIME',
|
74
|
+
proc: proc(&:to_i),
|
75
|
+
default: 2
|
76
|
+
|
77
|
+
def run
|
78
|
+
sent_at = Time.now
|
79
|
+
message = Digest::SHA256.hexdigest sent_at.to_i.to_s
|
80
|
+
|
81
|
+
msg = {
|
82
|
+
service: {
|
83
|
+
name: 'logstash-check'
|
84
|
+
},
|
85
|
+
message: message,
|
86
|
+
sent_at: sent_at.iso8601(10)
|
87
|
+
}
|
88
|
+
|
89
|
+
socket = TCPSocket.new(config[:logstash_host],
|
90
|
+
config[:logstash_port])
|
91
|
+
socket.puts(JSON.generate(msg))
|
92
|
+
socket.close
|
93
|
+
|
94
|
+
msearch1 = {index: ["logstash-*"]}
|
95
|
+
msearch2 = {
|
96
|
+
size: 5,
|
97
|
+
query: {
|
98
|
+
bool: {
|
99
|
+
must: [
|
100
|
+
{ query_string: { query: message } },
|
101
|
+
{
|
102
|
+
range: {
|
103
|
+
"@timestamp": {
|
104
|
+
gte: sent_at.to_i,
|
105
|
+
lte: sent_at.to_i + config[:timeout],
|
106
|
+
format: 'epoch_second'
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
]
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
body = "#{JSON.generate(msearch1)}\n#{JSON.generate(msearch2)}\n"
|
116
|
+
url = "#{config[:elasticsearch_url]}/_msearch"
|
117
|
+
|
118
|
+
tries = 0
|
119
|
+
found = 0
|
120
|
+
|
121
|
+
while Time.now.to_i - sent_at.to_i < config[:timeout]
|
122
|
+
sleep config[:elaticsearch_request_interval]
|
123
|
+
tries += 1
|
124
|
+
response = RestClient.post(url, body)
|
125
|
+
found = JSON.parse(response)['responses'][0]['hits']['total']
|
126
|
+
break if found > 0
|
127
|
+
end
|
128
|
+
|
129
|
+
duration = Time.now.to_i - sent_at.to_i
|
130
|
+
|
131
|
+
if found <= 0
|
132
|
+
critical "Event #{message} NOT found"
|
133
|
+
end
|
134
|
+
|
135
|
+
msg = "Event found (duration=#{duration}s, requests=#{tries}, results=#{found})"
|
136
|
+
if duration > config[:duration_critical]
|
137
|
+
critical msg
|
138
|
+
elsif duration > config[:duration_warning]
|
139
|
+
warning msg
|
140
|
+
else
|
141
|
+
ok msg
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -37,7 +37,7 @@ class CheckRabbitMQQueuesSynchronised < Sensu::Plugin::RabbitMQ::Check
|
|
37
37
|
queues = get_queues config
|
38
38
|
|
39
39
|
queues.each do |q|
|
40
|
-
next unless q.key?(
|
40
|
+
next unless q.key?('slave_nodes')
|
41
41
|
|
42
42
|
nb_slaves = q['slave_nodes'].count
|
43
43
|
next unless nb_slaves != 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -167,23 +167,25 @@ dependencies:
|
|
167
167
|
description: Sensu plugins developed by Edgelab
|
168
168
|
email:
|
169
169
|
executables:
|
170
|
-
- metrics-aws-
|
171
|
-
- metrics-swarm-cluster.rb
|
170
|
+
- metrics-aws-asg.rb
|
172
171
|
- metrics-redis-key-pattern.rb
|
173
|
-
- metrics-es-indices.rb
|
174
172
|
- check-apt-expired-keys.rb
|
175
173
|
- check-swarm-cluster.rb
|
176
|
-
- metrics-aws-
|
177
|
-
- metrics-aws-asg.rb
|
174
|
+
- metrics-aws-elb.rb
|
178
175
|
- check-consul-services.rb
|
179
|
-
-
|
176
|
+
- metrics-aws-rds.rb
|
177
|
+
- metrics-es-indices.rb
|
180
178
|
- check-nomad-leader.rb
|
179
|
+
- metrics-swarm-cluster.rb
|
180
|
+
- check-logstash-pipeline.rb
|
181
|
+
- check-rabbitmq-queues-synchronised.rb
|
181
182
|
- check-nomad-jobs.rb
|
182
183
|
extensions: []
|
183
184
|
extra_rdoc_files: []
|
184
185
|
files:
|
185
186
|
- bin/check-apt-expired-keys.rb
|
186
187
|
- bin/check-consul-services.rb
|
188
|
+
- bin/check-logstash-pipeline.rb
|
187
189
|
- bin/check-nomad-jobs.rb
|
188
190
|
- bin/check-nomad-leader.rb
|
189
191
|
- bin/check-rabbitmq-queues-synchronised.rb
|