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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1c9b47b908225a034886cf53e05210d7364b74ad
4
- data.tar.gz: 8519202e2e3a17afb71976483c3b828f67debd8e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWFmMjk2MzYxMGVkZmVlYTNjNzZiZmUyMmU3MDUzOTAwODU1NWFlYQ==
5
+ data.tar.gz: !binary |-
6
+ NzJjY2JlYjBkMDc1ZDY2MDgzNGRmMGYyNDMwMzQzYTJjMTNlNWJhYQ==
5
7
  SHA512:
6
- metadata.gz: d62bfe5b3e8ef036e99441179c2791e85be02decfe1101424a6aec46cc7a0f26b80ab8808150e19a9d84686a0f170e56ff8df33b0babc909519a76a53e195d3e
7
- data.tar.gz: 10875b3238b6744885485df857d6d137378e9a0adb5f96c0cc241af54dd22143215919d4a604e85889677754d0e19c45e4922bd8caa272753502ee7acfe7fbc6
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
- - nothing
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
- [unreleased]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.6...HEAD
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
  [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite)
6
6
  [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-graphite)
7
7
  [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-graphite.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-graphite)
8
- [![Codeship Status for sensu-plugins/sensu-plugins-graphite](https://codeship.com/projects/c6f4f5a0-db95-0132-445b-5ad94843e341/status?branch=master)](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-occurances**
37
+ **handler-graphite-occurrences**
39
38
  ```
40
39
  {
41
40
  "graphite": {
@@ -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 okay")
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 exists'
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 graphite server'
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 graphite server'
138
+ unknown 'Connection refused when connecting to Graphite server'
139
139
  rescue Errno::ECONNRESET
140
- unknown 'Connection reset by peer when connecting to graphite server'
140
+ unknown 'Connection reset by peer when connecting to Graphite server'
141
141
  rescue EOFError
142
- unknown 'End of file error when reading from graphite server'
142
+ unknown 'End of file error when reading from Graphite server'
143
143
  rescue => e
144
- unknown "An unknown error occured: #{e.inspect}"
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
- (!config[:below]) && (@data.last > config[type]) && (!decreased?)
164
+ !config[:below] && (@data.last > config[type]) && !decreased?
165
165
  end
166
166
 
167
167
  # Check if values have decreased within interval if given
@@ -3,7 +3,7 @@
3
3
  # check-graphite-hosts
4
4
  #
5
5
  # DESCRIPTION:
6
- # This plugin checks the number of hosts within graphite that are sending
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)}) okay")
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
- (!config[:below]) && (val > config[type])
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 graphite.
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 graphite key)
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 graphite server those
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 carbon relay servers to post to.',
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 graphite servers to check.',
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 dns') do
150
+ time_out('resolving DNS') do
151
151
  relays.each do |r|
152
- if IPAddress.valid? r
153
- relay_ips[r] = [r]
154
- else
155
- relay_ips[r] = Resolv.getaddresses(r)
156
- end
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 graphite api on #{server}") do
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.gsub(',', '_').gsub(' ', '_').gsub('.', '_').gsub('-', '_')
213
+ key.tr(',', '_').tr(' ', '_').tr('.', '_').tr('-', '_')
214
214
  end
215
215
 
216
216
  def time_out(activity, &block)
@@ -3,9 +3,9 @@
3
3
  # check-stats
4
4
  #
5
5
  # DESCRIPTION:
6
- # Checks metrics in graphite, averaged over a period of time.
6
+ # Checks metrics in Graphite, averaged over a period of time.
7
7
  #
8
- # The fired sensu event will only be critical if a stat is
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: 'graphite hostname',
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 graphite metric name. Can include * to query multiple metrics',
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 Crit',
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 for a few missing data)",
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 warning/crit scale (if value is less than instead of greater than)',
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 graphite: #{e.inspect}"
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 graphite' if data.empty?
140
+ unknown 'No data from Graphite' if data.empty?
141
141
 
142
142
  data.each do |metric|
143
143
  s, msg = danger(metric)
@@ -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
- resp = Net::HTTP.new(graphite_url.host, graphite_url.port).start { |http| http.request(req) }
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
- fail "Unknown type #{type}"
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
- fail "Unknown type #{type}"
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
- fail "Unknown type #{type}"
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 = last_graphite_metric target
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, last|
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 max allowed #{max_value}"
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
- fail "Unknown type #{type}"
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 graphite events URI.
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 graphite: #{body.to_json}"
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 graphite metric when an event is created and 0 when it's resolved
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'].gsub('.', '_')}.#{@event['check']['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'].split('.').first
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 graphite-like format for sensu events here
22
- check_occurences = "sensu.#{hostname}.#{check_name} #{value} #{now}"
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 check_occurences
30
+ sock.puts check_occurrences
31
31
  sock.close
32
32
  end
33
33
  rescue Timeout::Error
34
- puts 'graphite -- timed out while sending check occurrence'
34
+ puts 'Graphite -- timed out while sending check occurrence'
35
35
  rescue => error
36
- puts "graphite -- failed to send check occurrence: #{error}"
36
+ puts "Graphite -- failed to send check occurrence: #{error}"
37
37
  end
38
38
  end
39
39
  end
@@ -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 graphite tree view
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].gsub('.', '_'))
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: 'username for basic http authentication',
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: 'user password for basic http authentication',
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: 'password file path for basic http authentication',
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: 'alert if number of hosts below specified thresholds',
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 graphite server', exception: e)
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 graphite server', exception: e)
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 graphite server', exception: e)
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 graphite server', exception: e)
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 occured: #{e.inspect}", exception: e)
107
+ raise ProxyError.new("An unknown error occurred: #{e.inspect}", exception: e)
108
108
  end
109
109
  end
110
110
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsGraphite
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 0
5
- PATCH = 7
3
+ MAJOR = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  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: 0.0.7
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.32.1
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.32.1
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
- This plugin provides native Graphite instrumentation
233
- for monitoring, including: replication status,
234
- various Graphite data queries, mutators, and handlers
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: "@mattyjones"
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.8
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
@@ -1,3 +0,0 @@
1
- � s��l�
2
- ���!4��~�2!�~�4�c���?�����4?� ������G�t$�,?�6�c�G�ܘ�n-�P��_�k㗃�:3?�
3
- �qű���,�oe?�t#6�b��Y��!^f�����$P��HB�Bb2�s�-5l):�&�e��D?�l�+}�ἯD�ڠ�^ _�F�q�� ���
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- V��0r3k������� 壐(�ۙy
2
- ��%��m�g���ae�Ӥ���U�ń��ذ�z�h��\2 �9�a�Wܓg�c;I�TYN�|�8x��"}�浮���
3
- �0�����5�t�2%�i{"}+gh.��P8&6F�`�ۭQyI��hW���}��y+�Q�Ņ�w�T��'�𓋝x����㾀@@ŘP�o�{׈��W���j'����L�x!�ëO�Bcɽ�t�)���Y1�56�l�RVI