sensu-plugins-graphite 0.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/CHANGELOG.md +13 -2
- data/README.md +1 -2
- data/bin/check-graphite-data.rb +9 -9
- data/bin/check-graphite-hosts.rb +3 -3
- data/bin/check-graphite-replication.rb +13 -13
- data/bin/check-graphite-stats.rb +10 -10
- data/bin/check-graphite.rb +24 -13
- data/bin/handler-graphite-event.rb +2 -2
- data/bin/handler-graphite-notify.rb +2 -2
- data/bin/handler-graphite-occurrences.rb +6 -6
- data/bin/mutator-graphite.rb +10 -2
- data/lib/sensu-plugins-graphite/graphite_proxy/options.rb +11 -4
- data/lib/sensu-plugins-graphite/graphite_proxy/proxy.rb +5 -5
- data/lib/sensu-plugins-graphite/version.rb +3 -3
- metadata +39 -62
- checksums.yaml.gz.sig +0 -3
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWFmMjk2MzYxMGVkZmVlYTNjNzZiZmUyMmU3MDUzOTAwODU1NWFlYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzJjY2JlYjBkMDc1ZDY2MDgzNGRmMGYyNDMwMzQzYTJjMTNlNWJhYQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OGE3OGJkYmEwMTBiZjI4N2Q5M2UxOWM2YzBmMWM4ZmY4YmZjZDNiMTI1NjU4
|
10
|
+
ZjJkMzZkZWQ5NzI4ZTUyNTMxZmZhZDZjNmYwNjFiZmY2ZjRiNWM1YmE0NTY0
|
11
|
+
NTY0MjU1ZGFmZjhmNmIyMDMxNjY1MDhiMTlkZjQwMGVhZjQxOWQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZGNlZjQ5OThmNjNkMjYwMDkyMWVmYTE3MTIyMDQxNmVlZjg3NjgzYTNlMDE0
|
14
|
+
Nzg5MTNiNjM1MzQ1ODhlODJlMjQxOGNmM2NjNWE4YTIzYzMyMGY5YTUzYjcw
|
15
|
+
YzkyNDcxZThkYzA3MzE1YjU4MDUzZjhhYTI1MjY0NWQ1MjE2MWE=
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
|
-
|
7
|
+
|
8
|
+
## [1.1.0] - 2016-04-26
|
9
|
+
### Fixed
|
10
|
+
- fix comparison of number against array in --last.
|
11
|
+
- improve wording of --last help text.
|
12
|
+
|
13
|
+
## [1.0.0] - 2016-01-20
|
14
|
+
### Changed
|
15
|
+
- Use the whole client name as hostname for graphite measurement
|
8
16
|
|
9
17
|
## [0.0.7] - 2015-09-29
|
10
18
|
### Added
|
@@ -41,7 +49,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
41
49
|
### Added
|
42
50
|
- initial release
|
43
51
|
|
44
|
-
[
|
52
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/1.1.0...HEAD
|
53
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/1.0.0...1.1.0
|
54
|
+
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.7...1.0.0
|
55
|
+
[0.0.7]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.6...0.0.7
|
45
56
|
[0.0.6]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.5...0.0.6
|
46
57
|
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.4...0.0.5
|
47
58
|
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.3...0.0.4
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite)
|
6
6
|
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite)
|
7
7
|
[](https://gemnasium.com/sensu-plugins/sensu-plugins-graphite)
|
8
|
-
[](https://codeship.com/projects/79664)
|
9
8
|
|
10
9
|
## Functionality
|
11
10
|
|
@@ -35,7 +34,7 @@
|
|
35
34
|
}
|
36
35
|
```
|
37
36
|
|
38
|
-
**handler-graphite-
|
37
|
+
**handler-graphite-occurrences**
|
39
38
|
```
|
40
39
|
{
|
41
40
|
"graphite": {
|
data/bin/check-graphite-data.rb
CHANGED
@@ -65,7 +65,7 @@ class CheckGraphiteData < Sensu::Plugin::Check::CLI
|
|
65
65
|
check_age || check(:critical) || check(:warning)
|
66
66
|
end
|
67
67
|
|
68
|
-
ok("#{name} value
|
68
|
+
ok("#{name} value OK")
|
69
69
|
rescue SensuPluginsGraphite::GraphiteProxy::ProxyError => e
|
70
70
|
unknown e.message
|
71
71
|
end
|
@@ -92,7 +92,7 @@ class CheckGraphiteData < Sensu::Plugin::Check::CLI
|
|
92
92
|
config[:server].prepend('http://')
|
93
93
|
end
|
94
94
|
|
95
|
-
url = "#{config[:server]}/render?format=json&target=#{formatted_target}&from=#{config[:from]}"
|
95
|
+
url = "#{config[:server]}/render?format=json&target=#{formatted_target}&from=#{config[:from]}&until=#{config[:until]}"
|
96
96
|
|
97
97
|
url_opts = {}
|
98
98
|
|
@@ -114,7 +114,7 @@ class CheckGraphiteData < Sensu::Plugin::Check::CLI
|
|
114
114
|
|
115
115
|
@raw_data = handle.gets
|
116
116
|
if @raw_data == '[]'
|
117
|
-
unknown 'Empty data received from Graphite - metric probably doesn\'t
|
117
|
+
unknown 'Empty data received from Graphite - metric probably doesn\'t exist'
|
118
118
|
else
|
119
119
|
@json_data = JSON.parse(@raw_data)
|
120
120
|
output = {}
|
@@ -131,17 +131,17 @@ class CheckGraphiteData < Sensu::Plugin::Check::CLI
|
|
131
131
|
output
|
132
132
|
end
|
133
133
|
rescue OpenURI::HTTPError
|
134
|
-
unknown 'Failed to connect to
|
134
|
+
unknown 'Failed to connect to Graphite server'
|
135
135
|
rescue NoMethodError
|
136
136
|
unknown 'No data for time period and/or target'
|
137
137
|
rescue Errno::ECONNREFUSED
|
138
|
-
unknown 'Connection refused when connecting to
|
138
|
+
unknown 'Connection refused when connecting to Graphite server'
|
139
139
|
rescue Errno::ECONNRESET
|
140
|
-
unknown 'Connection reset by peer when connecting to
|
140
|
+
unknown 'Connection reset by peer when connecting to Graphite server'
|
141
141
|
rescue EOFError
|
142
|
-
unknown 'End of file error when reading from
|
142
|
+
unknown 'End of file error when reading from Graphite server'
|
143
143
|
rescue => e
|
144
|
-
unknown "An unknown error
|
144
|
+
unknown "An unknown error occurred: #{e.inspect}"
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
@@ -161,7 +161,7 @@ class CheckGraphiteData < Sensu::Plugin::Check::CLI
|
|
161
161
|
|
162
162
|
# Check is value is above defined threshold
|
163
163
|
def above?(type)
|
164
|
-
|
164
|
+
!config[:below] && (@data.last > config[type]) && !decreased?
|
165
165
|
end
|
166
166
|
|
167
167
|
# Check if values have decreased within interval if given
|
data/bin/check-graphite-hosts.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# check-graphite-hosts
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
|
-
# This plugin checks the number of hosts within
|
6
|
+
# This plugin checks the number of hosts within Graphite that are sending
|
7
7
|
# data, and alerts if it is below a given threshold
|
8
8
|
#
|
9
9
|
# OUTPUT:
|
@@ -49,7 +49,7 @@ class CheckGraphiteHosts < Sensu::Plugin::Check::CLI
|
|
49
49
|
results = proxy.retrieve_data!
|
50
50
|
|
51
51
|
check(:critical, results) || check(:warning, results)
|
52
|
-
ok("#{name} value (#{hosts_with_data(results)})
|
52
|
+
ok("#{name} value (#{hosts_with_data(results)}) OK")
|
53
53
|
rescue SensuPluginsGraphite::GraphiteProxy::ProxyError => e
|
54
54
|
unknown e.message
|
55
55
|
end
|
@@ -92,6 +92,6 @@ class CheckGraphiteHosts < Sensu::Plugin::Check::CLI
|
|
92
92
|
|
93
93
|
# Check is value is above defined threshold
|
94
94
|
def above?(type, val)
|
95
|
-
|
95
|
+
!config[:below] && (val > config[type])
|
96
96
|
end
|
97
97
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# check-replication
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
|
-
# Check to ensure data gets posted and is retrievable by
|
6
|
+
# Check to ensure data gets posted and is retrievable by Graphite.
|
7
7
|
# We post to each server in config[:relays] then sleep config[:sleep]
|
8
8
|
# seconds then check each of config[:graphites] to see if the data made it
|
9
9
|
# to each one. OK if all servers have the data we expected, WARN if
|
@@ -11,10 +11,10 @@
|
|
11
11
|
# or fewer have it. config[:check_id] allows you to have many of these
|
12
12
|
# checks running in different places without any conflicts. Customize it
|
13
13
|
# if you are going to run this check from multiple servers. Otherwise
|
14
|
-
# it defaults to default. (can be a descriptive string, used as a
|
14
|
+
# it defaults to default. (can be a descriptive string, used as a Graphite key)
|
15
15
|
#
|
16
16
|
# This check is most useful when you have a cluster of carbon-relays configured
|
17
|
-
# with REPLICATION_FACTOR > 1 and more than one
|
17
|
+
# with REPLICATION_FACTOR > 1 and more than one Graphite server those
|
18
18
|
# carbon-relays are configured to post to. This check ensures that replication
|
19
19
|
# is actually happening in a timely manner.
|
20
20
|
|
@@ -56,12 +56,12 @@ class CheckGraphiteReplication < Sensu::Plugin::Check::CLI
|
|
56
56
|
option :relays,
|
57
57
|
short: '-r RELAYS',
|
58
58
|
long: '--relays RELAYS',
|
59
|
-
description: 'Comma separated list of
|
59
|
+
description: 'Comma separated list of Carbon relay servers to post to.',
|
60
60
|
required: true
|
61
61
|
option :servers,
|
62
62
|
short: '-g SERVERS',
|
63
63
|
long: '--graphite SERVERS',
|
64
|
-
description: 'Comma separated list of all
|
64
|
+
description: 'Comma separated list of all Graphite servers to check.',
|
65
65
|
required: true
|
66
66
|
option :sleep,
|
67
67
|
short: '-s SECONDS',
|
@@ -147,13 +147,13 @@ class CheckGraphiteReplication < Sensu::Plugin::Check::CLI
|
|
147
147
|
|
148
148
|
relay_ips = {}
|
149
149
|
|
150
|
-
time_out('resolving
|
150
|
+
time_out('resolving DNS') do
|
151
151
|
relays.each do |r|
|
152
|
-
if IPAddress.valid? r
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
relay_ips[r] = if IPAddress.valid? r
|
153
|
+
[r]
|
154
|
+
else
|
155
|
+
Resolv.getaddresses(r)
|
156
|
+
end
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
@@ -190,7 +190,7 @@ class CheckGraphiteReplication < Sensu::Plugin::Check::CLI
|
|
190
190
|
graphite_data = nil
|
191
191
|
|
192
192
|
begin
|
193
|
-
time_out("querying
|
193
|
+
time_out("querying Graphite API on #{server}") do
|
194
194
|
graphite_data = RestClient.get url
|
195
195
|
graphite_data = JSON.parse(graphite_data)
|
196
196
|
end
|
@@ -210,7 +210,7 @@ class CheckGraphiteReplication < Sensu::Plugin::Check::CLI
|
|
210
210
|
end
|
211
211
|
|
212
212
|
def graphite_key(key)
|
213
|
-
key.
|
213
|
+
key.tr(',', '_').tr(' ', '_').tr('.', '_').tr('-', '_')
|
214
214
|
end
|
215
215
|
|
216
216
|
def time_out(activity, &block)
|
data/bin/check-graphite-stats.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
# check-stats
|
4
4
|
#
|
5
5
|
# DESCRIPTION:
|
6
|
-
# Checks metrics in
|
6
|
+
# Checks metrics in Graphite, averaged over a period of time.
|
7
7
|
#
|
8
|
-
# The fired
|
8
|
+
# The fired Sensu event will only be critical if a stat is
|
9
9
|
# above the critical threshold. Otherwise, the event will be warning,
|
10
10
|
# if a stat is above the warning threshold.
|
11
11
|
#
|
@@ -40,7 +40,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
40
40
|
option :host,
|
41
41
|
short: '-h HOST',
|
42
42
|
long: '--host HOST',
|
43
|
-
description: '
|
43
|
+
description: 'Graphite hostname',
|
44
44
|
proc: proc(&:to_s),
|
45
45
|
default: 'graphite'
|
46
46
|
|
@@ -54,7 +54,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
54
54
|
option :target,
|
55
55
|
short: '-t TARGET',
|
56
56
|
long: '--target TARGET',
|
57
|
-
description: 'The
|
57
|
+
description: 'The Graphite metric name. Can include * to query multiple metrics',
|
58
58
|
proc: proc(&:to_s),
|
59
59
|
required: true
|
60
60
|
|
@@ -66,7 +66,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
66
66
|
required: false
|
67
67
|
|
68
68
|
option :crit,
|
69
|
-
short: '-c
|
69
|
+
short: '-c CRIT',
|
70
70
|
long: '--crit CRIT',
|
71
71
|
description: 'Critical level',
|
72
72
|
proc: proc(&:to_f),
|
@@ -75,14 +75,14 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
75
75
|
option :unknown_ignore,
|
76
76
|
short: '-u',
|
77
77
|
long: '--unknown-ignore',
|
78
|
-
description: "Do nothing for UNKNOWN status (when you wildcard-match a ton of metrics at once and you don't care
|
78
|
+
description: "Do nothing for UNKNOWN status (when you wildcard-match a ton of metrics at once and you don't care about a few missing data)",
|
79
79
|
boolean: true,
|
80
80
|
default: false
|
81
81
|
|
82
82
|
option :reverse_scale,
|
83
83
|
short: '-r',
|
84
84
|
long: '--reverse-scale',
|
85
|
-
description: 'Reverse the
|
85
|
+
description: 'Reverse the warn/crit scale (if value is less than instead of greater than)',
|
86
86
|
boolean: true,
|
87
87
|
default: false
|
88
88
|
|
@@ -106,7 +106,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
106
106
|
return [1, "#{metric['target']} is #{avg}"]
|
107
107
|
end
|
108
108
|
else
|
109
|
-
if !config[:crit].nil? && avg < config[:crit]
|
109
|
+
if !config[:crit].nil? && avg < config[:crit] # rubocop:disable Style/IfInsideElse
|
110
110
|
return [2, "#{metric['target']} is #{avg}"]
|
111
111
|
elsif !config[:warn].nil? && avg < config[:warn]
|
112
112
|
return [1, "#{metric['target']} is #{avg}"]
|
@@ -125,7 +125,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
125
125
|
res = Net::HTTP.get_response(uri)
|
126
126
|
res.body
|
127
127
|
rescue => e
|
128
|
-
warning "Failed to query
|
128
|
+
warning "Failed to query Graphite: #{e.inspect}"
|
129
129
|
end
|
130
130
|
|
131
131
|
status = 0
|
@@ -137,7 +137,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
|
|
137
137
|
[]
|
138
138
|
end
|
139
139
|
|
140
|
-
unknown 'No data from
|
140
|
+
unknown 'No data from Graphite' if data.empty?
|
141
141
|
|
142
142
|
data.each do |metric|
|
143
143
|
s, msg = danger(metric)
|
data/bin/check-graphite.rb
CHANGED
@@ -30,6 +30,7 @@
|
|
30
30
|
require 'sensu-plugin/check/cli'
|
31
31
|
require 'json'
|
32
32
|
require 'net/http'
|
33
|
+
require 'net/https'
|
33
34
|
require 'socket'
|
34
35
|
require 'array_stats'
|
35
36
|
|
@@ -46,6 +47,12 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
46
47
|
long: '--target TARGET',
|
47
48
|
required: true
|
48
49
|
|
50
|
+
option :complex_target,
|
51
|
+
description: 'Allows complex targets which contain functions. Disables splitting on comma.',
|
52
|
+
short: '-x',
|
53
|
+
long: '--complex_target',
|
54
|
+
default: false
|
55
|
+
|
49
56
|
option :period,
|
50
57
|
description: 'The period back in time to extract from Graphite and compare with. Use 24hours,2days etc, same format as in Graphite',
|
51
58
|
short: '-p PERIOD',
|
@@ -193,7 +200,12 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
193
200
|
end
|
194
201
|
|
195
202
|
req.set_form_data(params)
|
196
|
-
|
203
|
+
nethttp = Net::HTTP.new(graphite_url.host, graphite_url.port)
|
204
|
+
if graphite_url.scheme == 'https'
|
205
|
+
nethttp.use_ssl = true
|
206
|
+
end
|
207
|
+
resp = nethttp.start { |http| http.request(req) }
|
208
|
+
|
197
209
|
data = JSON.parse(resp.body)
|
198
210
|
@graphite_cache[target] = []
|
199
211
|
if data.size > 0
|
@@ -335,7 +347,7 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
335
347
|
when 'fatal'
|
336
348
|
fatal << text
|
337
349
|
else
|
338
|
-
|
350
|
+
raise "Unknown type #{type}"
|
339
351
|
end
|
340
352
|
break if config[:short_output]
|
341
353
|
end
|
@@ -372,7 +384,7 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
372
384
|
when 'fatal'
|
373
385
|
fatal << text
|
374
386
|
else
|
375
|
-
|
387
|
+
raise "Unknown type #{type}"
|
376
388
|
end
|
377
389
|
break if config[:short_output]
|
378
390
|
end
|
@@ -412,7 +424,7 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
412
424
|
when 'fatal'
|
413
425
|
fatal << text
|
414
426
|
else
|
415
|
-
|
427
|
+
raise "Unknown type #{type}"
|
416
428
|
end
|
417
429
|
break if config[:short_output]
|
418
430
|
end
|
@@ -422,14 +434,13 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
422
434
|
end
|
423
435
|
|
424
436
|
def check_last(target, max_values)
|
425
|
-
last_targets =
|
437
|
+
last_targets = last_graphite_value target
|
426
438
|
return [[], [], []] unless last_targets
|
427
439
|
warnings = []
|
428
440
|
criticals = []
|
429
441
|
fatal = []
|
430
442
|
# #YELLOW
|
431
|
-
last_targets.each do |target_name,
|
432
|
-
last_value = last.first
|
443
|
+
last_targets.each do |target_name, last_value|
|
433
444
|
unless last_value.nil?
|
434
445
|
# #YELLOW
|
435
446
|
%w(fatal error warning).each do |type|
|
@@ -438,7 +449,7 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
438
449
|
var1 = config[:greater_than] ? last_value : max_value.to_f
|
439
450
|
var2 = config[:greater_than] ? max_value.to_f : last_value
|
440
451
|
if var1 > var2
|
441
|
-
text = "The metric #{target_name} is #{last_value} that is #{greater_less} than
|
452
|
+
text = "The metric #{target_name} is #{last_value} that is #{greater_less} than last allowed #{max_value}"
|
442
453
|
case type
|
443
454
|
when 'warning'
|
444
455
|
warnings << text
|
@@ -447,7 +458,7 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
447
458
|
when 'fatal'
|
448
459
|
fatal << text
|
449
460
|
else
|
450
|
-
|
461
|
+
raise "Unknown type #{type}"
|
451
462
|
end
|
452
463
|
break if config[:short_output]
|
453
464
|
end
|
@@ -457,8 +468,8 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
457
468
|
[warnings, criticals, fatal]
|
458
469
|
end
|
459
470
|
|
460
|
-
def run
|
461
|
-
targets = config[:target].split(',')
|
471
|
+
def run # rubocop:disable AbcSize
|
472
|
+
targets = config[:complex_target] ? [config[:target]] : config[:target].split(',')
|
462
473
|
@period = config[:period]
|
463
474
|
critical_errors = []
|
464
475
|
warnings = []
|
@@ -510,11 +521,11 @@ class Graphite < Sensu::Plugin::Check::CLI
|
|
510
521
|
criticals_string = criticals_string + "\nGraphite WARNING: " + warnings_string if warnings.size > 0
|
511
522
|
critical fatals_string if fatals.size > 0
|
512
523
|
critical criticals_string if critical_errors.size > 0
|
513
|
-
warning warnings_string if warnings.size > 0
|
524
|
+
warning warnings_string if warnings.size > 0 # rubocop:disable Style/IdenticalConditionalBranches
|
514
525
|
else
|
515
526
|
critical fatals_string if fatals.size > 0
|
516
527
|
critical criticals_string if critical_errors.size > 0
|
517
|
-
warning warnings_string if warnings.size > 0
|
528
|
+
warning warnings_string if warnings.size > 0 # rubocop:disable Style/IdenticalConditionalBranches
|
518
529
|
end
|
519
530
|
ok
|
520
531
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Sensu - Graphite Event Handler
|
4
4
|
#
|
5
|
-
# This handler takes events and POSTs them to a
|
5
|
+
# This handler takes events and POSTs them to a Graphite events URI.
|
6
6
|
#
|
7
7
|
# For configuration see: graphite_event.json
|
8
8
|
#
|
@@ -73,6 +73,6 @@ class GraphiteEvent < Sensu::Handler
|
|
73
73
|
bail "failed to send event to #{uri}: #{e}"
|
74
74
|
end
|
75
75
|
|
76
|
-
puts "sent event to
|
76
|
+
puts "sent event to Graphite: #{body.to_json}"
|
77
77
|
end
|
78
78
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
4
4
|
# for details
|
5
5
|
#
|
6
|
-
# This will send a 1 to a
|
6
|
+
# This will send a 1 to a Graphite metric when an event is created and 0 when it's resolved
|
7
7
|
# See http://imansson.wordpress.com/2012/11/26/why-sensu-is-a-monitoring-router-some-cool-handlers/
|
8
8
|
|
9
9
|
require 'sensu-handler'
|
@@ -15,7 +15,7 @@ class Resolve < Sensu::Handler
|
|
15
15
|
graphite = Graphite.new(host: settings['graphite_notify']['host'], port: port)
|
16
16
|
return unless graphite
|
17
17
|
prop = @event['action'] == 'create' ? 1 : 0
|
18
|
-
message = "#{settings['graphite_notify']['prefix']}.#{@event['client']['name'].
|
18
|
+
message = "#{settings['graphite_notify']['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}"
|
19
19
|
message += " #{prop} #{graphite.time_now + rand(100)}"
|
20
20
|
begin
|
21
21
|
graphite.push_to_graphite do |graphite_socket|
|
@@ -12,14 +12,14 @@ class GraphiteOccurrences < Sensu::Handler
|
|
12
12
|
def filter; end
|
13
13
|
|
14
14
|
def handle
|
15
|
-
hostname = @event['client']['name']
|
15
|
+
hostname = @event['client']['name']
|
16
16
|
# #YELLOW
|
17
17
|
check_name = @event['check']['name'].gsub(%r{[ \.]}, '_')
|
18
18
|
value = @event['action'] == 'create' ? @event['occurrences'] : 0
|
19
19
|
now = Time.now.to_i
|
20
20
|
|
21
|
-
# Get
|
22
|
-
|
21
|
+
# Get Graphite-like format for Sensu events here
|
22
|
+
check_occurrences = "sensu.#{hostname}.#{check_name} #{value} #{now}"
|
23
23
|
|
24
24
|
graphite_server = settings['graphite']['server']
|
25
25
|
graphite_port = settings['graphite']['port']
|
@@ -27,13 +27,13 @@ class GraphiteOccurrences < Sensu::Handler
|
|
27
27
|
begin
|
28
28
|
timeout(3) do
|
29
29
|
sock = TCPSocket.new(graphite_server, graphite_port)
|
30
|
-
sock.puts
|
30
|
+
sock.puts check_occurrences
|
31
31
|
sock.close
|
32
32
|
end
|
33
33
|
rescue Timeout::Error
|
34
|
-
puts '
|
34
|
+
puts 'Graphite -- timed out while sending check occurrence'
|
35
35
|
rescue => error
|
36
|
-
puts "
|
36
|
+
puts "Graphite -- failed to send check occurrence: #{error}"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/bin/mutator-graphite.rb
CHANGED
@@ -9,10 +9,18 @@
|
|
9
9
|
# (so you don't need to use OnlyCheckOutput) and it also modifies
|
10
10
|
# the format of the hostname in the output if present.
|
11
11
|
#
|
12
|
+
# Note however that using this mutator as a mutator command can be very
|
13
|
+
# expensive, as Sensu has to spawn a new Ruby process to launch this script
|
14
|
+
# for each result of a metrics check. Consider instead producing the correct
|
15
|
+
# metric names from your plugin and sending them directly to Graphite via the
|
16
|
+
# socket handler.
|
17
|
+
# See https://groups.google.com/d/msg/sensu-users/1hkRSvL48ck/8Dhl98lR24kJ
|
18
|
+
# for more information.
|
19
|
+
#
|
12
20
|
# OUTPUT:
|
13
21
|
# Sensu event output with all dots changed to underlines in host name
|
14
22
|
# If -r or --reverse parameter given script put hostname in reverse order
|
15
|
-
# for better
|
23
|
+
# for better Graphite tree view
|
16
24
|
#
|
17
25
|
# PLATFORM:
|
18
26
|
# all
|
@@ -32,5 +40,5 @@ event = JSON.parse(STDIN.read, symbolize_names: true)
|
|
32
40
|
if ARGV[0] == '-r' || ARGV[0] == '--reverse'
|
33
41
|
puts event[:check][:output].gsub(event[:client][:name], event[:client][:name].split('.').reverse.join('.'))
|
34
42
|
else
|
35
|
-
puts event[:check][:output].gsub(event[:client][:name], event[:client][:name].
|
43
|
+
puts event[:check][:output].gsub(event[:client][:name], event[:client][:name].tr('.', '_'))
|
36
44
|
end
|
@@ -28,21 +28,21 @@ module SensuPluginsGraphite
|
|
28
28
|
},
|
29
29
|
|
30
30
|
username: {
|
31
|
-
description: '
|
31
|
+
description: 'Username for basic HTTP authentication',
|
32
32
|
short: '-u USERNAME',
|
33
33
|
long: '--user USERNAME',
|
34
34
|
required: false
|
35
35
|
},
|
36
36
|
|
37
37
|
password: {
|
38
|
-
description: '
|
38
|
+
description: 'User password for basic HTTP authentication',
|
39
39
|
short: '-p PASSWORD',
|
40
40
|
long: '--pass PASSWORD',
|
41
41
|
required: false
|
42
42
|
},
|
43
43
|
|
44
44
|
passfile: {
|
45
|
-
description: '
|
45
|
+
description: 'Password file path for basic HTTP authentication',
|
46
46
|
short: '-P PASSWORDFILE',
|
47
47
|
long: '--passfile PASSWORDFILE',
|
48
48
|
required: false
|
@@ -87,6 +87,13 @@ module SensuPluginsGraphite
|
|
87
87
|
default: '-10mins'
|
88
88
|
},
|
89
89
|
|
90
|
+
until: {
|
91
|
+
description: 'Get samples ending at UNTIL (default: now)',
|
92
|
+
short: '-l UNTIL',
|
93
|
+
long: '--until UNTIL',
|
94
|
+
default: 'now'
|
95
|
+
},
|
96
|
+
|
90
97
|
warning: {
|
91
98
|
description: 'Generate warning if number of hosts is below received value',
|
92
99
|
short: '-w VALUE',
|
@@ -102,7 +109,7 @@ module SensuPluginsGraphite
|
|
102
109
|
},
|
103
110
|
|
104
111
|
below: {
|
105
|
-
description: '
|
112
|
+
description: 'Alert if number of hosts is below specified thresholds',
|
106
113
|
short: '-b',
|
107
114
|
long: '--below'
|
108
115
|
}
|
@@ -94,17 +94,17 @@ module SensuPluginsGraphite
|
|
94
94
|
format_output(json_data)
|
95
95
|
end
|
96
96
|
rescue OpenURI::HTTPError => e
|
97
|
-
raise ProxyError.new('Failed to connect to
|
97
|
+
raise ProxyError.new('Failed to connect to Graphite server', exception: e)
|
98
98
|
rescue NoMethodError => e
|
99
99
|
raise ProxyError.new('No data for time period and/or target', exception: e)
|
100
100
|
rescue Errno::ECONNREFUSED => e
|
101
|
-
raise ProxyError.new('Connection refused when connecting to
|
101
|
+
raise ProxyError.new('Connection refused when connecting to Graphite server', exception: e)
|
102
102
|
rescue Errno::ECONNRESET => e
|
103
|
-
raise ProxyError.new('Connection reset by peer when connecting to
|
103
|
+
raise ProxyError.new('Connection reset by peer when connecting to Graphite server', exception: e)
|
104
104
|
rescue EOFError => e
|
105
|
-
raise ProxyError.new('End of file error when reading from
|
105
|
+
raise ProxyError.new('End of file error when reading from Graphite server', exception: e)
|
106
106
|
rescue => e
|
107
|
-
raise ProxyError.new("An unknown error
|
107
|
+
raise ProxyError.new("An unknown error occurred: #{e.inspect}", exception: e)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
metadata
CHANGED
@@ -1,36 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
-
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
-
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
-
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
-
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
-
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
-
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
-
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
-
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
-
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
-
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
-
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
-
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
-
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
-
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
-
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
-
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
-
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
-
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
-
-----END CERTIFICATE-----
|
33
|
-
date: 2015-09-29 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
34
12
|
dependencies:
|
35
13
|
- !ruby/object:Gem::Dependency
|
36
14
|
name: array_stats
|
@@ -106,143 +84,142 @@ dependencies:
|
|
106
84
|
name: bundler
|
107
85
|
requirement: !ruby/object:Gem::Requirement
|
108
86
|
requirements:
|
109
|
-
- -
|
87
|
+
- - ~>
|
110
88
|
- !ruby/object:Gem::Version
|
111
89
|
version: '1.7'
|
112
90
|
type: :development
|
113
91
|
prerelease: false
|
114
92
|
version_requirements: !ruby/object:Gem::Requirement
|
115
93
|
requirements:
|
116
|
-
- -
|
94
|
+
- - ~>
|
117
95
|
- !ruby/object:Gem::Version
|
118
96
|
version: '1.7'
|
119
97
|
- !ruby/object:Gem::Dependency
|
120
98
|
name: codeclimate-test-reporter
|
121
99
|
requirement: !ruby/object:Gem::Requirement
|
122
100
|
requirements:
|
123
|
-
- -
|
101
|
+
- - ~>
|
124
102
|
- !ruby/object:Gem::Version
|
125
103
|
version: '0.4'
|
126
104
|
type: :development
|
127
105
|
prerelease: false
|
128
106
|
version_requirements: !ruby/object:Gem::Requirement
|
129
107
|
requirements:
|
130
|
-
- -
|
108
|
+
- - ~>
|
131
109
|
- !ruby/object:Gem::Version
|
132
110
|
version: '0.4'
|
133
111
|
- !ruby/object:Gem::Dependency
|
134
112
|
name: github-markup
|
135
113
|
requirement: !ruby/object:Gem::Requirement
|
136
114
|
requirements:
|
137
|
-
- -
|
115
|
+
- - ~>
|
138
116
|
- !ruby/object:Gem::Version
|
139
117
|
version: '1.3'
|
140
118
|
type: :development
|
141
119
|
prerelease: false
|
142
120
|
version_requirements: !ruby/object:Gem::Requirement
|
143
121
|
requirements:
|
144
|
-
- -
|
122
|
+
- - ~>
|
145
123
|
- !ruby/object:Gem::Version
|
146
124
|
version: '1.3'
|
147
125
|
- !ruby/object:Gem::Dependency
|
148
126
|
name: pry
|
149
127
|
requirement: !ruby/object:Gem::Requirement
|
150
128
|
requirements:
|
151
|
-
- -
|
129
|
+
- - ~>
|
152
130
|
- !ruby/object:Gem::Version
|
153
131
|
version: '0.10'
|
154
132
|
type: :development
|
155
133
|
prerelease: false
|
156
134
|
version_requirements: !ruby/object:Gem::Requirement
|
157
135
|
requirements:
|
158
|
-
- -
|
136
|
+
- - ~>
|
159
137
|
- !ruby/object:Gem::Version
|
160
138
|
version: '0.10'
|
161
139
|
- !ruby/object:Gem::Dependency
|
162
140
|
name: rake
|
163
141
|
requirement: !ruby/object:Gem::Requirement
|
164
142
|
requirements:
|
165
|
-
- -
|
143
|
+
- - ~>
|
166
144
|
- !ruby/object:Gem::Version
|
167
145
|
version: '10.0'
|
168
146
|
type: :development
|
169
147
|
prerelease: false
|
170
148
|
version_requirements: !ruby/object:Gem::Requirement
|
171
149
|
requirements:
|
172
|
-
- -
|
150
|
+
- - ~>
|
173
151
|
- !ruby/object:Gem::Version
|
174
152
|
version: '10.0'
|
175
153
|
- !ruby/object:Gem::Dependency
|
176
154
|
name: redcarpet
|
177
155
|
requirement: !ruby/object:Gem::Requirement
|
178
156
|
requirements:
|
179
|
-
- -
|
157
|
+
- - ~>
|
180
158
|
- !ruby/object:Gem::Version
|
181
159
|
version: '3.2'
|
182
160
|
type: :development
|
183
161
|
prerelease: false
|
184
162
|
version_requirements: !ruby/object:Gem::Requirement
|
185
163
|
requirements:
|
186
|
-
- -
|
164
|
+
- - ~>
|
187
165
|
- !ruby/object:Gem::Version
|
188
166
|
version: '3.2'
|
189
167
|
- !ruby/object:Gem::Dependency
|
190
168
|
name: rubocop
|
191
169
|
requirement: !ruby/object:Gem::Requirement
|
192
170
|
requirements:
|
193
|
-
- -
|
171
|
+
- - ~>
|
194
172
|
- !ruby/object:Gem::Version
|
195
|
-
version: 0.
|
173
|
+
version: '0.37'
|
196
174
|
type: :development
|
197
175
|
prerelease: false
|
198
176
|
version_requirements: !ruby/object:Gem::Requirement
|
199
177
|
requirements:
|
200
|
-
- -
|
178
|
+
- - ~>
|
201
179
|
- !ruby/object:Gem::Version
|
202
|
-
version: 0.
|
180
|
+
version: '0.37'
|
203
181
|
- !ruby/object:Gem::Dependency
|
204
182
|
name: rspec
|
205
183
|
requirement: !ruby/object:Gem::Requirement
|
206
184
|
requirements:
|
207
|
-
- -
|
185
|
+
- - ~>
|
208
186
|
- !ruby/object:Gem::Version
|
209
187
|
version: '3.1'
|
210
188
|
type: :development
|
211
189
|
prerelease: false
|
212
190
|
version_requirements: !ruby/object:Gem::Requirement
|
213
191
|
requirements:
|
214
|
-
- -
|
192
|
+
- - ~>
|
215
193
|
- !ruby/object:Gem::Version
|
216
194
|
version: '3.1'
|
217
195
|
- !ruby/object:Gem::Dependency
|
218
196
|
name: yard
|
219
197
|
requirement: !ruby/object:Gem::Requirement
|
220
198
|
requirements:
|
221
|
-
- -
|
199
|
+
- - ~>
|
222
200
|
- !ruby/object:Gem::Version
|
223
201
|
version: '0.8'
|
224
202
|
type: :development
|
225
203
|
prerelease: false
|
226
204
|
version_requirements: !ruby/object:Gem::Requirement
|
227
205
|
requirements:
|
228
|
-
- -
|
206
|
+
- - ~>
|
229
207
|
- !ruby/object:Gem::Version
|
230
208
|
version: '0.8'
|
231
|
-
description:
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
email: "<sensu-users@googlegroups.com>"
|
209
|
+
description: ! "This plugin provides native Graphite instrumentation\n for
|
210
|
+
monitoring, including: replication status,\n various
|
211
|
+
Graphite data queries, mutators, and handlers"
|
212
|
+
email: <sensu-users@googlegroups.com>
|
236
213
|
executables:
|
237
|
-
- mutator-graphite.rb
|
238
|
-
- handler-graphite-occurrences.rb
|
239
|
-
- handler-graphite-notify.rb
|
240
|
-
- handler-graphite-event.rb
|
241
|
-
- check-graphite.rb
|
242
|
-
- check-graphite-stats.rb
|
243
|
-
- check-graphite-replication.rb
|
244
|
-
- check-graphite-hosts.rb
|
245
214
|
- check-graphite-data.rb
|
215
|
+
- check-graphite-hosts.rb
|
216
|
+
- check-graphite-replication.rb
|
217
|
+
- check-graphite-stats.rb
|
218
|
+
- check-graphite.rb
|
219
|
+
- handler-graphite-event.rb
|
220
|
+
- handler-graphite-notify.rb
|
221
|
+
- handler-graphite-occurrences.rb
|
222
|
+
- mutator-graphite.rb
|
246
223
|
extensions: []
|
247
224
|
extra_rdoc_files: []
|
248
225
|
files:
|
@@ -266,7 +243,7 @@ homepage: https://github.com/sensu-plugins/sensu-plugins-graphite
|
|
266
243
|
licenses:
|
267
244
|
- MIT
|
268
245
|
metadata:
|
269
|
-
maintainer:
|
246
|
+
maintainer: ! '@mattyjones'
|
270
247
|
development_status: active
|
271
248
|
production_status: unstable - testing recommended
|
272
249
|
release_draft: 'false'
|
@@ -278,17 +255,17 @@ require_paths:
|
|
278
255
|
- lib
|
279
256
|
required_ruby_version: !ruby/object:Gem::Requirement
|
280
257
|
requirements:
|
281
|
-
- -
|
258
|
+
- - ! '>='
|
282
259
|
- !ruby/object:Gem::Version
|
283
260
|
version: 1.9.3
|
284
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
262
|
requirements:
|
286
|
-
- -
|
263
|
+
- - ! '>='
|
287
264
|
- !ruby/object:Gem::Version
|
288
265
|
version: '0'
|
289
266
|
requirements: []
|
290
267
|
rubyforge_project:
|
291
|
-
rubygems_version: 2.4.
|
268
|
+
rubygems_version: 2.4.5
|
292
269
|
signing_key:
|
293
270
|
specification_version: 4
|
294
271
|
summary: Sensu plugins for graphite
|
checksums.yaml.gz.sig
DELETED
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED