sensu-plugins-graphite 2.2.1 → 2.3.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: 652a431ad40e8910a4a2a006cce0d85577c7904a
4
- data.tar.gz: 47002818adf4e226e4b69a0d0ea470d1cee0f456
3
+ metadata.gz: c8723bd63f1daa64ac49473016cf5163521a3f5c
4
+ data.tar.gz: 213141cd8365208987bd97c04ee9b6be16079385
5
5
  SHA512:
6
- metadata.gz: e3145d2716aef707c3f20b545db71f698cb2c4026bb46165a77dc857fc5498f3d5d7a1887d6ffa63997bcf5db67a2abf9d280f2e7bd53df0e46802905be7977f
7
- data.tar.gz: 69cb43e03d65f78e047505912443b46a13b626aab6b17e2f3643ac78863bf78878ad05b270f253bd20d3d79119d708781f1b757c5d5a8818430e79030fdfc59f
6
+ metadata.gz: 2da33de6c6be603ade77bca6e452e3ddbacf96901d7a20401ed7289e1ebc256d7bb15aec4f33d3dd02cd73379a52932d0232f4d32dd87cc3029de65d675e830a
7
+ data.tar.gz: 04207e317401a8ce9363d5a9eaa63d26265a18ef97b4108860e54f65031dae05284b6d2a356e40db1a29007d14348d1ff1f14d4f4cdc5bb44ef0af3eebf9c6c4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.3.0] - 2017-10-19
9
+ ### Added
10
+ - example in readme for using the handlers (@scosist)
11
+ ### Changed
12
+ - Added option -j to handler-graphite-notify.rb and handler-graphite-status.rb to allow configuration scope to be defined on command line.
13
+
8
14
  ## [2.2.1] - 2017-06-13
9
15
  ### Fixed
10
16
  - Remove short options -s on hostname_sub, it was unusable. This affects check-graphite-data and check check-graphite-hosts
@@ -78,6 +84,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
78
84
  - initial release
79
85
 
80
86
  [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.2.1...HEAD
87
+ [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.2.1...2.3.0
81
88
  [2.2.1]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.2.0...2.2.1
82
89
  [2.2.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.1.0...2.2.0
83
90
  [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-graphite/compare/2.0.0...2.1.0
data/README.md CHANGED
@@ -16,12 +16,13 @@
16
16
  * bin/extension-graphite
17
17
  * bin/handler-graphite-event
18
18
  * bin/handler-graphite-notify
19
+ * bin/handler-graphite-status
19
20
  * bin/handler-graphite-occurrences
20
21
  * bin/mutator-graphite
21
22
 
22
23
  ## Usage
23
24
 
24
- **handler-graphite-event**
25
+ ### handler-graphite-event
25
26
  ```
26
27
  {
27
28
  "graphite_event": {
@@ -34,7 +35,7 @@
34
35
  }
35
36
  ```
36
37
 
37
- **handler-graphite-occurrences**
38
+ ### handler-graphite-occurrences
38
39
  ```
39
40
  {
40
41
  "graphite": {
@@ -44,7 +45,7 @@
44
45
  }
45
46
  ```
46
47
 
47
- **handler-graphite-notify**
48
+ ### handler-graphite-notify
48
49
  ```
49
50
  {
50
51
  "graphite_notify": {
@@ -55,10 +56,10 @@
55
56
  }
56
57
  ```
57
58
 
58
- **handler-graphite-status**
59
+ ### handler-graphite-status
59
60
  ```
60
61
  {
61
- "graphite_notify": {
62
+ "graphite_status": {
62
63
  "host":"graphite.example.com",
63
64
  "port":"2003",
64
65
  "prefix":"sensu.events"
@@ -66,6 +67,59 @@
66
67
  }
67
68
  ```
68
69
 
70
+ ## Full Configuration Example
71
+ +**Note that TCP Handler is preferred**
72
+ ```
73
+ {
74
+ "graphite_event": {
75
+ "server_uri": "https://graphite.example.com:443/events/",
76
+ "tags": [
77
+ "custom_tag_a",
78
+ "custom_tag_b"
79
+ ]
80
+ },
81
+ "handlers":
82
+ {
83
+ "default": {
84
+ "type": "set",
85
+ "handlers": [
86
+ "graphite_event"
87
+ ]
88
+ },
89
+ "graphite_tcp": {
90
+ "type": "tcp",
91
+ "socket": {
92
+ "host":"graphite.example.com",
93
+ "port":2003
94
+ },
95
+ "mutator": "only_check_output"
96
+ },
97
+ "graphite_event": {
98
+ "type": "pipe",
99
+ "filters": [
100
+ "custom_filter_a",
101
+ "custom_filter_b"
102
+ ],
103
+ "command": "handler-graphite-event.rb"
104
+ }
105
+ },
106
+ "checks": {
107
+ "metrics_uptime": {
108
+ "standalone": true,
109
+ "type": "metric",
110
+ "handlers": [
111
+ "graphite_tcp"
112
+ ],
113
+ "interval": 60,
114
+ "command": "metrics-uptime.rb --scheme sensu.host.$(hostname).uptime",
115
+ "subscribers": [
116
+ "core"
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
69
123
  ## Installation
70
124
 
71
125
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -5,24 +5,35 @@
5
5
  #
6
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
+ #
9
+ # Config by default is graphite_notify, but can be called with a specific json config
10
+ # using the -j option. This allows multiple graphite handlers to be configured.
8
11
 
9
12
  require 'sensu-handler'
10
13
  require 'simple-graphite'
11
14
 
12
15
  class Resolve < Sensu::Handler
16
+ option :json_config,
17
+ description: 'Config Name',
18
+ short: '-j JsonConfig',
19
+ long: '--json_config JsonConfig',
20
+ required: false,
21
+ default: 'graphite_notify'
22
+
13
23
  def handle
14
- port = settings['graphite_notify']['port'] ? settings['graphite_notify']['port'].to_s : '2003'
15
- graphite = Graphite.new(host: settings['graphite_notify']['host'], port: port)
24
+ json_config = config[:json_config]
25
+ port = settings[json_config]['port'] ? settings[json_config]['port'].to_s : '2003'
26
+ graphite = Graphite.new(host: settings[json_config]['host'], port: port)
16
27
  return unless graphite
17
28
  prop = @event['action'] == 'create' ? 1 : 0
18
- message = "#{settings['graphite_notify']['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}"
29
+ message = "#{settings[json_config]['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}"
19
30
  message += " #{prop} #{graphite.time_now + rand(100)}"
20
31
  begin
21
32
  graphite.push_to_graphite do |graphite_socket|
22
33
  graphite_socket.puts message
23
34
  end
24
- rescue => e
25
- error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}: #{e}'"
35
+ rescue ETIMEDOUT
36
+ error_msg = "Can't connect to #{settings[json_config]['host']}:#{port} and send message #{message}'"
26
37
  raise error_msg
27
38
  end
28
39
  end
@@ -4,29 +4,37 @@
4
4
  # for details
5
5
  #
6
6
  # This will send the check status (0,1,2,3) to a graphite metric when a check event state changes
7
- # Based on handler-graphite-notify.rb
8
- # See http://imansson.wordpress.com/2012/11/26/why-sensu-is-a-monitoring-router-some-cool-handlers/
7
+ # Based on handler-graphite-notify.rb.
8
+ # Config by default is graphite_status but can be called with a specific json config
9
+ # using the -j option. This allows multiple graphite handlers to be configured.
9
10
 
10
11
  require 'sensu-handler'
11
12
  require 'simple-graphite'
12
13
 
13
14
  class Resolve < Sensu::Handler
15
+ option :json_config,
16
+ description: 'Config Name',
17
+ short: '-j JsonConfig',
18
+ long: '--json_config JsonConfig',
19
+ required: false,
20
+ default: 'graphite_status'
14
21
  # override filters from Sensu::Handler. not appropriate for metric handlers
15
22
  def filter; end
16
23
 
17
24
  def handle
18
- port = settings['graphite_notify']['port'] ? settings['graphite_notify']['port'].to_s : '2003'
19
- graphite = Graphite.new(host: settings['graphite_notify']['host'], port: port)
25
+ json_config = config[:json_config]
26
+ port = settings[json_config]['port'] ? settings[json_config]['port'].to_s : '2003'
27
+ graphite = Graphite.new(host: settings[json_config]['host'], port: port)
20
28
  return unless graphite
21
29
  prop = @event['check']['status']
22
- message = "#{settings['graphite_notify']['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}"
30
+ message = "#{settings[json_config]['prefix']}.#{@event['client']['name'].tr('.', '_')}.#{@event['check']['name']}"
23
31
  message += " #{prop} #{graphite.time_now + rand(100)}"
24
32
  begin
25
33
  graphite.push_to_graphite do |graphite_socket|
26
34
  graphite_socket.puts message
27
35
  end
28
- rescue => e
29
- error_msg = "Can't connect to #{settings['graphite_notify']['host']}:#{port} and send message #{message}: #{e}'"
36
+ rescue ETIMEDOUT
37
+ error_msg = "Can't connect to #{settings[json_config]['host']}:#{port} and send message #{message}'"
30
38
  raise error_msg
31
39
  end
32
40
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsGraphite
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 2
5
- PATCH = 1
4
+ MINOR = 3
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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.2.1
4
+ version: 2.3.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: 2017-06-14 00:00:00.000000000 Z
11
+ date: 2017-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_stats
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: '0'
269
269
  requirements: []
270
270
  rubyforge_project:
271
- rubygems_version: 2.4.5
271
+ rubygems_version: 2.6.14
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Sensu plugins for graphite