riemann-tools 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +8 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +25 -2
  7. data/Rakefile +10 -3
  8. data/bin/riemann-apache-status +1 -106
  9. data/bin/riemann-bench +2 -70
  10. data/bin/riemann-cloudant +1 -56
  11. data/bin/riemann-consul +1 -106
  12. data/bin/riemann-dir-files-count +1 -55
  13. data/bin/riemann-dir-space +1 -55
  14. data/bin/riemann-diskstats +1 -92
  15. data/bin/riemann-fd +2 -81
  16. data/bin/riemann-freeswitch +2 -119
  17. data/bin/riemann-haproxy +1 -58
  18. data/bin/riemann-health +0 -2
  19. data/bin/riemann-kvminstance +2 -22
  20. data/bin/riemann-memcached +1 -37
  21. data/bin/riemann-net +0 -2
  22. data/bin/riemann-nginx-status +1 -85
  23. data/bin/riemann-ntp +0 -2
  24. data/bin/riemann-portcheck +1 -44
  25. data/bin/riemann-proc +1 -108
  26. data/bin/riemann-varnish +1 -54
  27. data/bin/riemann-wrapper +75 -0
  28. data/bin/riemann-zookeeper +1 -39
  29. data/lib/riemann/tools/apache_status.rb +107 -0
  30. data/lib/riemann/tools/bench.rb +72 -0
  31. data/lib/riemann/tools/cloudant.rb +57 -0
  32. data/lib/riemann/tools/consul_health.rb +107 -0
  33. data/lib/riemann/tools/dir_files_count.rb +56 -0
  34. data/lib/riemann/tools/dir_space.rb +56 -0
  35. data/lib/riemann/tools/diskstats.rb +94 -0
  36. data/lib/riemann/tools/fd.rb +81 -0
  37. data/lib/riemann/tools/freeswitch.rb +119 -0
  38. data/lib/riemann/tools/haproxy.rb +59 -0
  39. data/lib/riemann/tools/health.rb +150 -19
  40. data/lib/riemann/tools/kvm.rb +23 -0
  41. data/lib/riemann/tools/memcached.rb +38 -0
  42. data/lib/riemann/tools/net.rb +2 -1
  43. data/lib/riemann/tools/nginx_status.rb +86 -0
  44. data/lib/riemann/tools/ntp.rb +1 -0
  45. data/lib/riemann/tools/portcheck.rb +45 -0
  46. data/lib/riemann/tools/proc.rb +109 -0
  47. data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
  48. data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
  49. data/lib/riemann/tools/varnish.rb +55 -0
  50. data/lib/riemann/tools/version.rb +1 -1
  51. data/lib/riemann/tools/zookeeper.rb +40 -0
  52. data/lib/riemann/tools.rb +2 -20
  53. data/riemann-tools.gemspec +4 -1
  54. data/tools/riemann-aws/Rakefile +6 -9
  55. data/tools/riemann-aws/bin/riemann-aws-billing +2 -87
  56. data/tools/riemann-aws/bin/riemann-aws-rds-status +2 -62
  57. data/tools/riemann-aws/bin/riemann-aws-sqs-status +2 -44
  58. data/tools/riemann-aws/bin/riemann-aws-status +2 -77
  59. data/tools/riemann-aws/bin/riemann-elb-metrics +2 -162
  60. data/tools/riemann-aws/bin/riemann-s3-list +2 -81
  61. data/tools/riemann-aws/bin/riemann-s3-status +2 -96
  62. data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
  63. data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
  64. data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
  65. data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
  66. data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
  67. data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
  68. data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
  69. data/tools/riemann-chronos/Rakefile +6 -9
  70. data/tools/riemann-chronos/bin/riemann-chronos +1 -154
  71. data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
  72. data/tools/riemann-docker/Rakefile +5 -8
  73. data/tools/riemann-docker/bin/riemann-docker +2 -200
  74. data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
  75. data/tools/riemann-elasticsearch/Rakefile +6 -9
  76. data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +1 -167
  77. data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
  78. data/tools/riemann-marathon/Rakefile +6 -9
  79. data/tools/riemann-marathon/bin/riemann-marathon +1 -156
  80. data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
  81. data/tools/riemann-mesos/Rakefile +6 -9
  82. data/tools/riemann-mesos/bin/riemann-mesos +1 -139
  83. data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
  84. data/tools/riemann-munin/Rakefile +5 -8
  85. data/tools/riemann-munin/bin/riemann-munin +1 -36
  86. data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
  87. data/tools/riemann-rabbitmq/Rakefile +6 -9
  88. data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +1 -266
  89. data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
  90. data/tools/riemann-riak/Rakefile +5 -8
  91. data/tools/riemann-riak/bin/riemann-riak +1 -316
  92. data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
  93. data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
  94. data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
  95. metadata +57 -10
  96. data/.travis.yml +0 -31
  97. data/tools/riemann-riak/riak_status/key_count.erl +0 -13
  98. data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
  99. data/tools/riemann-riak/riak_status/ringready.erl +0 -9
@@ -3,41 +3,6 @@
3
3
 
4
4
  Process.setproctitle($PROGRAM_NAME)
5
5
 
6
- # Gathers munin statistics and submits them to Riemann.
7
-
8
- require 'riemann/tools'
9
-
10
- module Riemann
11
- module Tools
12
- class Munin
13
- include Riemann::Tools
14
- require 'munin-ruby'
15
-
16
- def initialize
17
- @munin = ::Munin::Node.new
18
- end
19
-
20
- def tick
21
- services = opts[:services] || @munin.list
22
- services.each do |service_name|
23
- @munin.fetch(service_name).each do |service, parts|
24
- parts.each do |part, metric|
25
- report(
26
- service: "#{service} #{part}",
27
- metric: metric.to_f,
28
- state: 'ok',
29
- tags: ['munin'],
30
- )
31
- end
32
- end
33
- end
34
- end
35
-
36
- opt :munin_host, 'Munin hostname', default: 'localhost'
37
- opt :munin_port, 'Munin port', default: 4949
38
- opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
39
- end
40
- end
41
- end
6
+ require 'riemann/tools/munin'
42
7
 
43
8
  Riemann::Tools::Munin.run
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'riemann/tools'
4
+
5
+ # Gathers munin statistics and submits them to Riemann.
6
+ module Riemann
7
+ module Tools
8
+ class Munin
9
+ include Riemann::Tools
10
+ require 'munin-ruby'
11
+
12
+ def initialize
13
+ @munin = ::Munin::Node.new
14
+ end
15
+
16
+ def tick
17
+ services = opts[:services] || @munin.list
18
+ services.each do |service_name|
19
+ @munin.fetch(service_name).each do |service, parts|
20
+ parts.each do |part, metric|
21
+ report(
22
+ service: "#{service} #{part}",
23
+ metric: metric.to_f,
24
+ state: 'ok',
25
+ tags: ['munin'],
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ opt :munin_host, 'Munin hostname', default: 'localhost'
33
+ opt :munin_port, 'Munin port', default: 4949
34
+ opt :services, 'Munin services to translate (if not specified, all services are relayed)', type: :strings
35
+ end
36
+ end
37
+ end
@@ -11,10 +11,8 @@ ENV['COPYFILE_DISABLE'] = 'true'
11
11
 
12
12
  # Gemspec
13
13
  gemspec = Gem::Specification.new do |s|
14
- s.rubyforge_project = 'riemann-rabbitmq'
15
-
16
14
  s.name = 'riemann-rabbitmq'
17
- s.version = '0.1.3'
15
+ s.version = '0.1.5'
18
16
  s.author = 'Gavin Sandie'
19
17
  s.email = 'beach@vicecity.co.uk'
20
18
  s.homepage = 'https://github.com/riemann/riemann-tools'
@@ -22,15 +20,14 @@ gemspec = Gem::Specification.new do |s|
22
20
  s.summary = 'Submits RabbitMQ stats to riemann.'
23
21
  s.license = 'MIT'
24
22
 
25
- s.add_dependency 'riemann-tools', '>= 0.2.13'
26
- s.add_dependency 'faraday', '>= 0.8.5'
27
- s.add_dependency 'json'
23
+ s.add_runtime_dependency 'riemann-tools', '~> 1.0', '>= 1.1.1'
24
+ s.add_runtime_dependency 'faraday', '~> 2.3', '>= 2.3.0'
25
+ s.add_runtime_dependency 'json', '~> 2.6', '>=2.6.2'
28
26
 
29
- s.files = FileList['bin/*', 'LICENSE', 'README.md'].to_a
27
+ s.files = FileList['bin/*', 'lib/**/*.rb', 'LICENSE', 'README.md'].to_a
30
28
  s.executables |= Dir.entries('bin/')
31
- s.has_rdoc = false
32
29
 
33
- s.required_ruby_version = '>= 1.8.7'
30
+ s.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
34
31
  end
35
32
 
36
33
  Gem::PackageTask.new gemspec do |p|
@@ -3,271 +3,6 @@
3
3
 
4
4
  Process.setproctitle($PROGRAM_NAME)
5
5
 
6
- require 'riemann/tools'
6
+ require 'riemann/tools/rabbitmq'
7
7
 
8
- module Riemann
9
- module Tools
10
- class Rabbitmq
11
- include Riemann::Tools
12
-
13
- require 'faraday'
14
- require 'json'
15
- require 'uri'
16
-
17
- opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
18
- opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
19
-
20
- opt :monitor_user, 'RabbitMQ monitoring user', type: :string
21
- opt :monitor_pass, 'RabbitMQ monitoring user password', type: :string
22
- opt :monitor_port, 'RabbitMQ monitoring port', type: :int, default: 15_672
23
- opt :monitor_host, 'RabbitMQ monitoring host', type: :string, default: 'localhost'
24
- opt :monitor_use_tls, 'RabbitMQ use tls', type: :bool, default: false
25
-
26
- opt :max_queue_size, 'max number of items in a queue that is acceptable', type: :int, default: 1_000_000
27
- opt :ignore_max_size_queues, "A regular expression to match queues that shouldn't be size-checked", type: :string
28
-
29
- opt :node, 'Specify a node to monitor', type: :strings
30
-
31
- def base_url
32
- protocol = 'http'
33
- protocol = 'https' if options[:monitor_use_tls] && (options[:monitor_use_tls] == true)
34
- "#{protocol}://#{options[:monitor_user]}:#{options[:monitor_pass]}@#{options[:monitor_host]}:#{options[:monitor_port]}/api"
35
- end
36
-
37
- def overview_url
38
- "#{base_url}/overview"
39
- end
40
-
41
- def node_url(node)
42
- "#{base_url}/nodes/#{node}"
43
- end
44
-
45
- def queues_url
46
- "#{base_url}/queues"
47
- end
48
-
49
- def event_host
50
- options[:event_host] || :monitor_host
51
- end
52
-
53
- def safe_get(uri, event_host)
54
- # Handle connection timeouts
55
- response = nil
56
- begin
57
- connection = Faraday.new(uri)
58
- response = connection.get do |req|
59
- req.options[:timeout] = options[:read_timeout]
60
- req.options[:open_timeout] = options[:open_timeout]
61
- end
62
- report(
63
- host: event_host,
64
- service: 'rabbitmq monitoring',
65
- state: 'ok',
66
- description: 'Monitoring operational',
67
- )
68
- rescue StandardError => e
69
- report(
70
- host: event_host,
71
- service: 'rabbitmq monitoring',
72
- state: 'critical',
73
- description: "HTTP connection error: #{e.class} - #{e.message}",
74
- )
75
- end
76
- response
77
- end
78
-
79
- def check_queues
80
- response = safe_get(queues_url, event_host)
81
- max_size_check_filter = (Regexp.new(options[:ignore_max_size_queues]) if options[:ignore_max_size_queues])
82
-
83
- return if response.nil?
84
-
85
- if response.status != 200
86
- report(
87
- host: event_host,
88
- service: 'rabbitmq.queue',
89
- state: 'critical',
90
- description: "HTTP connection error to /api/queues: #{response.status} - #{response.body}",
91
- )
92
- else
93
- report(
94
- host: event_host,
95
- service: 'rabbitmq.queue',
96
- state: 'ok',
97
- description: 'HTTP connection ok',
98
- )
99
-
100
- json = JSON.parse(response.body)
101
-
102
- json.each do |queue|
103
- svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
104
- errs = []
105
-
106
- errs << 'Queue has jobs but no consumers' if !queue['messages_ready'].nil? && (queue['messages_ready']).positive? && (queue['consumers']).zero?
107
-
108
- errs << "Queue has #{queue['messages_ready']} jobs" if (max_size_check_filter.nil? || queue['name'] !~ (max_size_check_filter)) && !queue['messages_ready'].nil? && (queue['messages_ready'] > options[:max_queue_size])
109
-
110
- if errs.empty?
111
- report(
112
- host: event_host,
113
- service: svc,
114
- state: 'ok',
115
- description: 'Queue is looking good',
116
- )
117
- else
118
- report(
119
- host: event_host,
120
- service: svc,
121
- state: 'critical',
122
- description: errs.join('; '),
123
- )
124
- end
125
-
126
- stats = (queue['message_stats'] || {}).merge(
127
- 'messages' => queue['messages'],
128
- 'messages_details' => queue['messages_details'],
129
- 'messages_ready' => queue['messages_ready'],
130
- 'messages_ready_details' => queue['messages_ready_details'],
131
- 'messages_unacknowledged' => queue['messages_unacknowledged'],
132
- 'messages_unacknowledged_details' => queue['messages_unacknowledged_details'],
133
- 'consumers' => queue['consumers'],
134
- 'memory' => queue['memory'],
135
- )
136
-
137
- stats.each_pair do |k, v|
138
- service = "#{svc}.#{k}"
139
- metric = if k =~ (/details$/) && !v.nil?
140
- v['rate']
141
- else
142
- v
143
- end
144
-
145
- # TODO: Set state via thresholds which can be configured
146
-
147
- report(
148
- host: event_host,
149
- service: service,
150
- metric: metric,
151
- description: 'RabbitMQ monitor',
152
- )
153
- end
154
- end
155
- end
156
- end
157
-
158
- def check_overview
159
- uri = URI(overview_url)
160
- response = safe_get(uri, event_host)
161
-
162
- return if response.nil?
163
-
164
- json = JSON.parse(response.body)
165
-
166
- if response.status != 200
167
- report(
168
- host: event_host,
169
- service: 'rabbitmq',
170
- state: 'critical',
171
- description: "HTTP connection error: #{response.status} - #{response.body}",
172
- )
173
- else
174
- report(
175
- host: event_host,
176
- service: 'rabbitmq monitoring',
177
- state: 'ok',
178
- description: 'HTTP connection ok',
179
- )
180
-
181
- %w[message_stats queue_totals object_totals].each do |stat|
182
- # NOTE: / BUG ?
183
- # Brand new servers can have blank message stats. Is this ok?
184
- # I can't decide.
185
- next if json[stat].empty?
186
-
187
- json[stat].each_pair do |k, v|
188
- service = "rabbitmq.#{stat}.#{k}"
189
- metric = if k =~ /details$/
190
- v['rate']
191
- else
192
- v
193
- end
194
-
195
- # TODO: Set state via thresholds which can be configured
196
-
197
- report(
198
- host: event_host,
199
- service: service,
200
- metric: metric,
201
- description: 'RabbitMQ monitor',
202
- )
203
- end
204
- end
205
- end
206
- end
207
-
208
- def check_node
209
- opts[:node].each do |n|
210
- uri = URI(node_url(n))
211
- response = safe_get(uri, event_host)
212
-
213
- break if response.nil?
214
-
215
- if response.status != 200
216
- if response.status == 404
217
- report(
218
- host: event_host,
219
- service: "rabbitmq.node.#{n}",
220
- state: 'critical',
221
- description: 'Node was not found in the cluster',
222
- )
223
- else
224
- report(
225
- host: event_host,
226
- service: "rabbitmq.node.#{n}",
227
- state: 'critical',
228
- description: "HTTP error: #{response.status} - #{response.body}",
229
- )
230
- end
231
- break
232
- end
233
-
234
- json = JSON.parse(response.body)
235
-
236
- if json['mem_alarm']
237
- report(
238
- host: event_host,
239
- service: "rabbitmq.node.#{n}",
240
- state: 'critical',
241
- description: 'Memory alarm has triggered; job submission throttled',
242
- )
243
- break
244
- end
245
-
246
- if json['disk_free_alarm']
247
- report(
248
- host: event_host,
249
- service: "rabbitmq.node.#{n}",
250
- state: 'critical',
251
- description: 'Disk free alarm has triggered; job submission throttled',
252
- )
253
- break
254
- end
255
-
256
- report(
257
- host: event_host,
258
- service: "rabbitmq.node.#{n}",
259
- state: 'ok',
260
- description: 'Node looks OK to me',
261
- )
262
- end
263
- end
264
-
265
- def tick
266
- check_overview
267
- check_node if opts[:node]
268
- check_queues
269
- end
270
- end
271
- end
272
- end
273
8
  Riemann::Tools::Rabbitmq.run
@@ -0,0 +1,269 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'riemann/tools'
4
+
5
+ module Riemann
6
+ module Tools
7
+ class Rabbitmq
8
+ include Riemann::Tools
9
+
10
+ require 'faraday'
11
+ require 'json'
12
+ require 'uri'
13
+
14
+ opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
15
+ opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
16
+
17
+ opt :monitor_user, 'RabbitMQ monitoring user', type: :string
18
+ opt :monitor_pass, 'RabbitMQ monitoring user password', type: :string
19
+ opt :monitor_port, 'RabbitMQ monitoring port', type: :int, default: 15_672
20
+ opt :monitor_host, 'RabbitMQ monitoring host', type: :string, default: 'localhost'
21
+ opt :monitor_use_tls, 'RabbitMQ use tls', type: :bool, default: false
22
+
23
+ opt :max_queue_size, 'max number of items in a queue that is acceptable', type: :int, default: 1_000_000
24
+ opt :ignore_max_size_queues, "A regular expression to match queues that shouldn't be size-checked", type: :string
25
+
26
+ opt :node, 'Specify a node to monitor', type: :strings
27
+
28
+ def base_url
29
+ protocol = 'http'
30
+ protocol = 'https' if options[:monitor_use_tls] && (options[:monitor_use_tls] == true)
31
+ "#{protocol}://#{options[:monitor_user]}:#{options[:monitor_pass]}@#{options[:monitor_host]}:#{options[:monitor_port]}/api"
32
+ end
33
+
34
+ def overview_url
35
+ "#{base_url}/overview"
36
+ end
37
+
38
+ def node_url(node)
39
+ "#{base_url}/nodes/#{node}"
40
+ end
41
+
42
+ def queues_url
43
+ "#{base_url}/queues"
44
+ end
45
+
46
+ def event_host
47
+ options[:event_host] || :monitor_host
48
+ end
49
+
50
+ def safe_get(uri, event_host)
51
+ # Handle connection timeouts
52
+ response = nil
53
+ begin
54
+ connection = Faraday.new(uri)
55
+ response = connection.get do |req|
56
+ req.options[:timeout] = options[:read_timeout]
57
+ req.options[:open_timeout] = options[:open_timeout]
58
+ end
59
+ report(
60
+ host: event_host,
61
+ service: 'rabbitmq monitoring',
62
+ state: 'ok',
63
+ description: 'Monitoring operational',
64
+ )
65
+ rescue StandardError => e
66
+ report(
67
+ host: event_host,
68
+ service: 'rabbitmq monitoring',
69
+ state: 'critical',
70
+ description: "HTTP connection error: #{e.class} - #{e.message}",
71
+ )
72
+ end
73
+ response
74
+ end
75
+
76
+ def check_queues
77
+ response = safe_get(queues_url, event_host)
78
+ max_size_check_filter = (Regexp.new(options[:ignore_max_size_queues]) if options[:ignore_max_size_queues])
79
+
80
+ return if response.nil?
81
+
82
+ if response.status != 200
83
+ report(
84
+ host: event_host,
85
+ service: 'rabbitmq.queue',
86
+ state: 'critical',
87
+ description: "HTTP connection error to /api/queues: #{response.status} - #{response.body}",
88
+ )
89
+ else
90
+ report(
91
+ host: event_host,
92
+ service: 'rabbitmq.queue',
93
+ state: 'ok',
94
+ description: 'HTTP connection ok',
95
+ )
96
+
97
+ json = JSON.parse(response.body)
98
+
99
+ json.each do |queue|
100
+ svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
101
+ errs = []
102
+
103
+ errs << 'Queue has jobs but no consumers' if !queue['messages_ready'].nil? && (queue['messages_ready']).positive? && (queue['consumers']).zero?
104
+
105
+ errs << "Queue has #{queue['messages_ready']} jobs" if (max_size_check_filter.nil? || queue['name'] !~ (max_size_check_filter)) && !queue['messages_ready'].nil? && (queue['messages_ready'] > options[:max_queue_size])
106
+
107
+ if errs.empty?
108
+ report(
109
+ host: event_host,
110
+ service: svc,
111
+ state: 'ok',
112
+ description: 'Queue is looking good',
113
+ )
114
+ else
115
+ report(
116
+ host: event_host,
117
+ service: svc,
118
+ state: 'critical',
119
+ description: errs.join('; '),
120
+ )
121
+ end
122
+
123
+ stats = (queue['message_stats'] || {}).merge(
124
+ 'messages' => queue['messages'],
125
+ 'messages_details' => queue['messages_details'],
126
+ 'messages_ready' => queue['messages_ready'],
127
+ 'messages_ready_details' => queue['messages_ready_details'],
128
+ 'messages_unacknowledged' => queue['messages_unacknowledged'],
129
+ 'messages_unacknowledged_details' => queue['messages_unacknowledged_details'],
130
+ 'consumers' => queue['consumers'],
131
+ 'memory' => queue['memory'],
132
+ )
133
+
134
+ stats.each_pair do |k, v|
135
+ service = "#{svc}.#{k}"
136
+ metric = if k =~ (/details$/) && !v.nil?
137
+ v['rate']
138
+ else
139
+ v
140
+ end
141
+
142
+ # TODO: Set state via thresholds which can be configured
143
+
144
+ report(
145
+ host: event_host,
146
+ service: service,
147
+ metric: metric,
148
+ description: 'RabbitMQ monitor',
149
+ )
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ def check_overview
156
+ uri = URI(overview_url)
157
+ response = safe_get(uri, event_host)
158
+
159
+ return if response.nil?
160
+
161
+ json = JSON.parse(response.body)
162
+
163
+ if response.status != 200
164
+ report(
165
+ host: event_host,
166
+ service: 'rabbitmq',
167
+ state: 'critical',
168
+ description: "HTTP connection error: #{response.status} - #{response.body}",
169
+ )
170
+ else
171
+ report(
172
+ host: event_host,
173
+ service: 'rabbitmq monitoring',
174
+ state: 'ok',
175
+ description: 'HTTP connection ok',
176
+ )
177
+
178
+ %w[message_stats queue_totals object_totals].each do |stat|
179
+ # NOTE: / BUG ?
180
+ # Brand new servers can have blank message stats. Is this ok?
181
+ # I can't decide.
182
+ next if json[stat].empty?
183
+
184
+ json[stat].each_pair do |k, v|
185
+ service = "rabbitmq.#{stat}.#{k}"
186
+ metric = if k =~ /details$/
187
+ v['rate']
188
+ else
189
+ v
190
+ end
191
+
192
+ # TODO: Set state via thresholds which can be configured
193
+
194
+ report(
195
+ host: event_host,
196
+ service: service,
197
+ metric: metric,
198
+ description: 'RabbitMQ monitor',
199
+ )
200
+ end
201
+ end
202
+ end
203
+ end
204
+
205
+ def check_node
206
+ opts[:node].each do |n|
207
+ uri = URI(node_url(n))
208
+ response = safe_get(uri, event_host)
209
+
210
+ break if response.nil?
211
+
212
+ if response.status != 200
213
+ if response.status == 404
214
+ report(
215
+ host: event_host,
216
+ service: "rabbitmq.node.#{n}",
217
+ state: 'critical',
218
+ description: 'Node was not found in the cluster',
219
+ )
220
+ else
221
+ report(
222
+ host: event_host,
223
+ service: "rabbitmq.node.#{n}",
224
+ state: 'critical',
225
+ description: "HTTP error: #{response.status} - #{response.body}",
226
+ )
227
+ end
228
+ break
229
+ end
230
+
231
+ json = JSON.parse(response.body)
232
+
233
+ if json['mem_alarm']
234
+ report(
235
+ host: event_host,
236
+ service: "rabbitmq.node.#{n}",
237
+ state: 'critical',
238
+ description: 'Memory alarm has triggered; job submission throttled',
239
+ )
240
+ break
241
+ end
242
+
243
+ if json['disk_free_alarm']
244
+ report(
245
+ host: event_host,
246
+ service: "rabbitmq.node.#{n}",
247
+ state: 'critical',
248
+ description: 'Disk free alarm has triggered; job submission throttled',
249
+ )
250
+ break
251
+ end
252
+
253
+ report(
254
+ host: event_host,
255
+ service: "rabbitmq.node.#{n}",
256
+ state: 'ok',
257
+ description: 'Node looks OK to me',
258
+ )
259
+ end
260
+ end
261
+
262
+ def tick
263
+ check_overview
264
+ check_node if opts[:node]
265
+ check_queues
266
+ end
267
+ end
268
+ end
269
+ end
@@ -11,10 +11,8 @@ ENV['COPYFILE_DISABLE'] = 'true'
11
11
 
12
12
  # Gemspec
13
13
  gemspec = Gem::Specification.new do |s|
14
- s.rubyforge_project = 'riemann-riak'
15
-
16
14
  s.name = 'riemann-riak'
17
- s.version = '0.1.2'
15
+ s.version = '0.1.4'
18
16
  s.author = 'Kyle Kingsbury'
19
17
  s.email = 'aphyr@aphyr.com'
20
18
  s.homepage = 'https://github.com/riemann/riemann-tools'
@@ -22,14 +20,13 @@ gemspec = Gem::Specification.new do |s|
22
20
  s.summary = 'Submits riak stats to riemann.'
23
21
  s.license = 'MIT'
24
22
 
25
- s.add_dependency 'riemann-tools', '>= 0.2.13'
26
- s.add_dependency 'yajl-ruby', '>= 1.1.0'
23
+ s.add_runtime_dependency 'riemann-tools', '~> 1.0', '>= 1.1.1'
24
+ s.add_runtime_dependency 'yajl-ruby', '~> 1.4', '>= 1.4.3'
27
25
 
28
- s.files = FileList['bin/*', 'LICENSE', 'README.md'].to_a
26
+ s.files = FileList['bin/*', 'lib/**/*.rb', 'LICENSE', 'README.md'].to_a
29
27
  s.executables |= Dir.entries('bin/')
30
- s.has_rdoc = false
31
28
 
32
- s.required_ruby_version = '>= 1.8.7'
29
+ s.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
33
30
  end
34
31
 
35
32
  Gem::PackageTask.new gemspec do |p|