sensu-plugins-graphite 2.0.0 → 2.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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a7efb937f12618e44c6e26727cb375e1a6b8e03
4
- data.tar.gz: 2788478ba370507eedb8d162dfc54e11dc43bdcf
3
+ metadata.gz: 8331eec9eb6a5f9cf9247c209a05cbd4735c67c4
4
+ data.tar.gz: a0add0a78abe919a5c43f8df3241f1123ce09ffa
5
5
  SHA512:
6
- metadata.gz: 37266b0ff1aecee96edad07b21765cb66198ba2166220622658c21ac605f5be2ec25b0c4c3983f18897d095667ed70181d68dc2fb9ae9576f0e59f36d9aed679
7
- data.tar.gz: 6db3acba2e2794d4c87dedfec5499f11625638716652b68bc57bfe029d3a0a031a58e76bac98cf7e44410dcc7b1a29859435177d9b7d0533909506472bc8d5e5
6
+ metadata.gz: 7e0ada3c1be5f354b91f03955036e15efbc79a180dfcece3135d743a148eac9fd5ae9c5698d6c5050ff9a82fdbe92cf86a759bb5b59b5805a448aae012c3a9d7
7
+ data.tar.gz: 928b1e29800fe91a4f951a4059786179a19b8954f37f244c6cd74dae05a0982ec2f25b67f3abe36e86fd73a98a4f1e3d405a60a81e920e90ecdbdd365850337e
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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
+ ## [2.1.0]
8
+ ### Changed
9
+ - Disable filtering for handler-graphite-status.rb
10
+ ### Fixed
11
+ - Error handling in graphite handlers
12
+ - Duplicate short option in check-graphite.rb
7
13
 
8
14
  ## [2.0.0] - 2016-06-21
9
15
  ### Added
@@ -62,7 +68,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
62
68
  ### Added
63
69
  - initial release
64
70
 
65
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.0.0...HEAD
71
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.1.0...HEAD
72
+ [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.0.0...2.1.0
66
73
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/1.1.0...2.0.0
67
74
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/1.0.0...1.1.0
68
75
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/0.0.7...1.0.0
data/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  * bin/extension-graphite
17
17
  * bin/handler-graphite-event
18
18
  * bin/handler-graphite-notify
19
- * bin/handler-graphite-occurances
19
+ * bin/handler-graphite-occurrences
20
20
  * bin/mutator-graphite
21
21
 
22
22
  ## Usage
@@ -142,7 +142,7 @@ class CheckGraphiteStat < Sensu::Plugin::Check::CLI
142
142
  data.each do |metric|
143
143
  s, msg = danger(metric)
144
144
 
145
- message += "#{msg} " unless s == 0
145
+ message += "#{msg} " unless s.zero?
146
146
  status = s unless s < status
147
147
  end
148
148
 
@@ -67,14 +67,14 @@ class Graphite < Sensu::Plugin::Check::CLI
67
67
 
68
68
  option :acceptable_diff_percentage,
69
69
  description: 'The acceptable diff from max values in percentage, used in check_function_increasing',
70
- short: '-d ACCEPTABLE_DIFF_PERCENTAGE',
70
+ short: '-D ACCEPTABLE_DIFF_PERCENTAGE',
71
71
  long: '--acceptable_diff_percentage ACCEPTABLE_DIFF_PERCENTAGE',
72
72
  default: 0
73
73
 
74
74
  option :check_function_increasing,
75
75
  description: 'Check that value is increasing or equal over time (use acceptable_diff_percentage if it should allow to be lower)',
76
76
  short: '-i',
77
- long: '--check_function_decreasing',
77
+ long: '--check_function_increasing',
78
78
  default: false,
79
79
  boolean: true
80
80
 
@@ -26,7 +26,7 @@ class GraphiteEvent < Sensu::Handler
26
26
  uri = URI.parse(uri)
27
27
  req = Net::HTTP::Post.new(uri.path)
28
28
  sock = Net::HTTP.new(uri.host, uri.port)
29
- sock.use_ssl = uri.scheme == 'https' ? true : false
29
+ sock.use_ssl = uri.scheme == 'https'
30
30
  req.body = body
31
31
 
32
32
  req.basic_auth(uri.user, uri.password) if uri.user
@@ -21,8 +21,8 @@ class Resolve < Sensu::Handler
21
21
  graphite.push_to_graphite do |graphite_socket|
22
22
  graphite_socket.puts message
23
23
  end
24
- rescue ETIMEDOUT
25
- error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}'"
24
+ rescue => e
25
+ error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}: #{e}'"
26
26
  raise error_msg
27
27
  end
28
28
  end
@@ -11,6 +11,9 @@ require 'sensu-handler'
11
11
  require 'simple-graphite'
12
12
 
13
13
  class Resolve < Sensu::Handler
14
+ # override filters from Sensu::Handler. not appropriate for metric handlers
15
+ def filter; end
16
+
14
17
  def handle
15
18
  port = settings['graphite_notify']['port'] ? settings['graphite_notify']['port'].to_s : '2003'
16
19
  graphite = Graphite.new(host: settings['graphite_notify']['host'], port: port)
@@ -22,8 +25,8 @@ class Resolve < Sensu::Handler
22
25
  graphite.push_to_graphite do |graphite_socket|
23
26
  graphite_socket.puts message
24
27
  end
25
- rescue ETIMEDOUT
26
- error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}'"
28
+ rescue => e
29
+ error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}: #{e}'"
27
30
  raise error_msg
28
31
  end
29
32
  end
@@ -3,10 +3,7 @@ require 'open-uri'
3
3
  module SensuPluginsGraphite
4
4
  module GraphiteProxy
5
5
  class ProxyError < StandardError
6
- attr_accessor :exception
7
-
8
- def initialize(msg, args)
9
- self.exception = args[:exception]
6
+ def initialize(msg)
10
7
  super msg
11
8
  end
12
9
  end
@@ -87,24 +84,20 @@ module SensuPluginsGraphite
87
84
  handle = open(url, request_auth_options(config))
88
85
 
89
86
  @raw_data = handle.gets
90
- if @raw_data == '[]'
91
- unknown 'Empty data received from Graphite - metric probably doesn\'t exists'
92
- else
93
- json_data = JSON.parse(@raw_data)
94
- format_output(json_data)
95
- end
96
- rescue OpenURI::HTTPError => e
97
- raise ProxyError.new('Failed to connect to Graphite server', exception: e)
98
- rescue NoMethodError => e
99
- raise ProxyError.new('No data for time period and/or target', exception: e)
100
- rescue Errno::ECONNREFUSED => e
101
- raise ProxyError.new('Connection refused when connecting to Graphite server', exception: e)
102
- rescue Errno::ECONNRESET => e
103
- raise ProxyError.new('Connection reset by peer when connecting to Graphite server', exception: e)
104
- rescue EOFError => e
105
- raise ProxyError.new('End of file error when reading from Graphite server', exception: e)
87
+ json_data = JSON.parse(@raw_data)
88
+ format_output(json_data)
89
+ rescue OpenURI::HTTPError
90
+ raise ProxyError, 'Failed to connect to Graphite server'
91
+ rescue NoMethodError, JSON::ParserError
92
+ raise ProxyError, 'No data for time period and/or target'
93
+ rescue Errno::ECONNREFUSED
94
+ raise ProxyError, 'Connection refused when connecting to Graphite server'
95
+ rescue Errno::ECONNRESET
96
+ raise ProxyError, 'Connection reset by peer when connecting to Graphite server'
97
+ rescue EOFError
98
+ raise ProxyError, 'End of file error when reading from Graphite server'
106
99
  rescue => e
107
- raise ProxyError.new("An unknown error occurred: #{e.inspect}", exception: e)
100
+ raise ProxyError, "An unknown error occurred: #{e.inspect}"
108
101
  end
109
102
  end
110
103
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsGraphite
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_stats
@@ -268,9 +268,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: '0'
269
269
  requirements: []
270
270
  rubyforge_project:
271
- rubygems_version: 2.5.1
271
+ rubygems_version: 2.4.5
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Sensu plugins for graphite
275
275
  test_files: []
276
- has_rdoc: