riemann-tools 1.11.0 → 2.0.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3 -3
  3. data/.github/workflows/codeql-analysis.yml +4 -4
  4. data/.rubocop.yml +1 -1
  5. data/CHANGELOG.md +65 -10
  6. data/Gemfile +1 -11
  7. data/README.markdown +4 -3
  8. data/lib/riemann/tools/apache_status.rb +1 -0
  9. data/lib/riemann/tools/bench.rb +6 -5
  10. data/lib/riemann/tools/cloudant.rb +1 -0
  11. data/lib/riemann/tools/haproxy.rb +1 -0
  12. data/lib/riemann/tools/health.rb +7 -5
  13. data/lib/riemann/tools/hwmon.rb +24 -7
  14. data/lib/riemann/tools/mdstat_parser.tab.rb +137 -127
  15. data/lib/riemann/tools/memcached.rb +1 -0
  16. data/lib/riemann/tools/nginx_status.rb +1 -0
  17. data/lib/riemann/tools/portcheck.rb +1 -0
  18. data/lib/riemann/tools/riemann_client_wrapper.rb +49 -6
  19. data/lib/riemann/tools/tls_check.rb +4 -2
  20. data/lib/riemann/tools/uptime_parser.tab.rb +1 -1
  21. data/lib/riemann/tools/version.rb +1 -1
  22. data/lib/riemann/tools/zookeeper.rb +1 -0
  23. data/lib/riemann/tools.rb +4 -1
  24. data/riemann-tools.gemspec +5 -4
  25. data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +1 -0
  26. data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +1 -0
  27. data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +1 -0
  28. data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +1 -0
  29. data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +1 -0
  30. data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +1 -0
  31. data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +1 -0
  32. data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +4 -4
  33. data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +3 -2
  34. data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +4 -4
  35. data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +4 -4
  36. data/tools/riemann-munin/lib/riemann/tools/munin.rb +1 -0
  37. data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +3 -3
  38. data/tools/riemann-riak/lib/riemann/tools/riak.rb +3 -2
  39. metadata +18 -4
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.7.3
3
+ # This file is automatically generated by Racc 1.8.1
4
4
  # from Racc grammar file "mdstat_parser.y".
5
5
  #
6
6
 
@@ -15,7 +15,7 @@ module Riemann
15
15
  module Tools
16
16
  class MdstatParser < Racc::Parser
17
17
 
18
- module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
18
+ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 62)
19
19
 
20
20
  def parse(text)
21
21
  s = Utils::StringTokenizer.new(text)
@@ -23,7 +23,7 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
23
23
  until s.eos? do
24
24
  case
25
25
  when s.scan(/\n/) then s.push_token(nil)
26
- when s.scan(/\s+/) then s.push_token(nil)
26
+ when s.scan(/[[:blank:]]+/) then s.push_token(nil)
27
27
 
28
28
  when s.scan(/\([WJFSR]\)/) then s.push_token(:DISK_STATUS)
29
29
  when s.scan(/<none>/) then s.push_token(:NONE)
@@ -40,6 +40,7 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
40
40
  when s.scan(/\[/) then s.push_token('[')
41
41
  when s.scan(/]/) then s.push_token(']')
42
42
 
43
+ when s.scan(/auto-read-only\b/) then s.push_token(:AUTO_READ_ONLY)
43
44
  when s.scan(/DELAYED\b/) then s.push_token(:DELAYED)
44
45
  when s.scan(/KB\b/) then s.push_token(:BYTE_UNIT)
45
46
  when s.scan(/K\/sec\b/) then s.push_token(:SPEED_UNIT)
@@ -89,154 +90,157 @@ module_eval(<<'...end mdstat_parser.y/module_eval...', 'mdstat_parser.y', 58)
89
90
  ##### State transition tables begin ###
90
91
 
91
92
  racc_action_table = [
92
- 60, 17, 10, 53, 54, 15, 73, 55, 56, 14,
93
- 3, 13, 10, 28, 4, 7, 12, 61, 72, 62,
94
- 63, 11, 71, 18, 19, 20, 21, 22, 23, 24,
95
- 10, 27, 30, 32, 34, 35, 36, 37, 38, 39,
96
- 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
97
- 50, 51, 58, 64, 65, 66, 67, 68, 69, 70,
98
- 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
99
- 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
100
- 94, 95, 96, 97, 98, 99, 100 ]
93
+ 64, 17, 10, 57, 58, 15, 77, 59, 60, 14,
94
+ 3, 13, 10, 32, 4, 7, 12, 65, 76, 66,
95
+ 67, 11, 75, 18, 19, 20, 21, 22, 24, 25,
96
+ 26, 27, 28, 10, 31, 34, 36, 38, 39, 40,
97
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
98
+ 51, 52, 53, 54, 55, 62, 68, 69, 70, 71,
99
+ 72, 73, 74, 78, 79, 80, 81, 82, 83, 84,
100
+ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
101
+ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104 ]
101
102
 
102
103
  racc_action_check = [
103
- 53, 11, 5, 50, 50, 11, 66, 50, 50, 10,
104
- 0, 10, 25, 25, 1, 4, 6, 53, 66, 53,
105
- 53, 5, 66, 12, 13, 14, 16, 18, 19, 20,
106
- 23, 24, 28, 30, 31, 32, 33, 34, 36, 37,
107
- 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
108
- 48, 49, 52, 54, 55, 56, 58, 59, 64, 65,
109
- 67, 68, 74, 75, 76, 77, 78, 79, 80, 81,
110
- 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
111
- 92, 93, 94, 95, 97, 98, 99 ]
104
+ 57, 11, 5, 54, 54, 11, 70, 54, 54, 10,
105
+ 0, 10, 29, 29, 1, 4, 6, 57, 70, 57,
106
+ 57, 5, 70, 12, 13, 14, 16, 18, 19, 20,
107
+ 23, 24, 25, 26, 27, 32, 34, 35, 36, 37,
108
+ 38, 40, 41, 42, 43, 44, 45, 46, 47, 48,
109
+ 49, 50, 51, 52, 53, 56, 58, 59, 60, 62,
110
+ 63, 68, 69, 71, 72, 78, 79, 80, 81, 82,
111
+ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
112
+ 93, 94, 95, 96, 97, 98, 99, 101, 102, 103 ]
112
113
 
113
114
  racc_action_pointer = [
114
- -8, 14, nil, nil, 15, -10, -16, nil, nil, nil,
115
- -23, -11, 4, 12, 12, nil, 14, nil, -6, 9,
116
- -4, nil, nil, 18, 22, 0, nil, nil, 28, nil,
117
- 4, 20, 24, 4, 24, nil, 25, 3, 5, 28,
118
- 29, 13, 11, 38, 14, 11, 36, 47, 17, 38,
119
- -18, nil, 49, -6, 16, 17, 18, nil, 22, 20,
120
- nil, nil, nil, nil, 34, 35, -2, 47, 50, nil,
121
- nil, nil, nil, nil, 27, 25, 51, 26, 49, 54,
122
- 36, 34, 57, 58, 67, 33, 41, 65, 40, 40,
123
- 65, 68, 75, 66, 75, 56, nil, 47, 72, 58,
124
- nil ]
115
+ -9, 14, nil, nil, 15, -11, -17, nil, nil, nil,
116
+ -24, -12, 3, 11, 11, nil, 13, nil, -7, -9,
117
+ -5, nil, nil, 10, 28, 22, 20, -4, nil, -1,
118
+ nil, nil, 30, nil, 6, 22, 26, 6, 26, nil,
119
+ 27, 3, 7, 30, 31, 15, 13, 40, 16, 11,
120
+ 38, 50, 19, 40, -19, nil, 51, -7, 16, 17,
121
+ 18, nil, 24, 20, nil, nil, nil, nil, 36, 37,
122
+ -3, 49, 52, nil, nil, nil, nil, nil, 29, 25,
123
+ 53, 31, 51, 56, 38, 36, 59, 60, 69, 38,
124
+ 43, 67, 40, 40, 67, 70, 77, 68, 77, 58,
125
+ nil, 47, 74, 60, nil ]
125
126
 
126
127
  racc_action_default = [
127
- -33, -33, -6, -4, -33, -33, -2, 101, -1, -5,
128
- -33, -33, -33, -33, -33, -29, -30, -32, -33, -33,
129
- -33, -31, -3, -33, -11, -33, -9, -10, -33, -8,
130
- -13, -15, -33, -33, -33, -12, -33, -33, -33, -33,
131
- -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
132
- -24, -14, -17, -33, -33, -33, -33, -7, -33, -33,
133
- -25, -26, -27, -28, -33, -33, -33, -33, -33, -19,
134
- -20, -21, -22, -23, -33, -33, -33, -33, -33, -33,
135
- -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
136
- -33, -33, -33, -33, -33, -33, -16, -33, -33, -33,
137
- -18 ]
128
+ -35, -35, -6, -4, -35, -35, -2, 105, -1, -5,
129
+ -35, -35, -35, -35, -35, -31, -32, -34, -35, -9,
130
+ -35, -33, -3, -35, -35, -13, -35, -35, -12, -35,
131
+ -11, -8, -35, -10, -15, -17, -35, -35, -35, -14,
132
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
133
+ -35, -35, -35, -35, -26, -16, -19, -35, -35, -35,
134
+ -35, -7, -35, -35, -27, -28, -29, -30, -35, -35,
135
+ -35, -35, -35, -21, -22, -23, -24, -25, -35, -35,
136
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
137
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
138
+ -18, -35, -35, -35, -20 ]
138
139
 
139
140
  racc_goto_table = [
140
- 9, 1, 2, 5, 8, 6, 25, 31, 33, 52,
141
- 57, 59, 16, nil, nil, nil, nil, nil, 26, nil,
142
- 29 ]
141
+ 9, 1, 2, 5, 8, 6, 23, 29, 35, 37,
142
+ 56, 61, 63, 16, nil, nil, nil, nil, nil, nil,
143
+ nil, 30, nil, nil, 33 ]
143
144
 
144
145
  racc_goto_check = [
145
146
  6, 1, 2, 3, 4, 5, 7, 8, 9, 10,
146
- 11, 12, 13, nil, nil, nil, nil, nil, 6, nil,
147
- 6 ]
147
+ 11, 12, 13, 14, nil, nil, nil, nil, nil, nil,
148
+ nil, 6, nil, nil, 6 ]
148
149
 
149
150
  racc_goto_pointer = [
150
- nil, 1, 2, 1, -1, 2, -5, -17, -23, -23,
151
- -41, -42, -42, 1 ]
151
+ nil, 1, 2, 1, -1, 2, -5, -13, -19, -26,
152
+ -26, -44, -45, -45, 2 ]
152
153
 
153
154
  racc_goto_default = [
154
155
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
155
- nil, nil, nil, nil ]
156
+ nil, nil, nil, nil, nil ]
156
157
 
157
158
  racc_reduce_table = [
158
159
  0, 0, :racc_error,
159
- 3, 42, :_reduce_1,
160
- 2, 43, :_reduce_none,
161
- 4, 46, :_reduce_none,
162
- 0, 46, :_reduce_none,
163
- 2, 44, :_reduce_5,
164
- 0, 44, :_reduce_6,
165
- 19, 47, :_reduce_7,
166
- 2, 48, :_reduce_none,
167
- 1, 48, :_reduce_none,
168
- 5, 47, :_reduce_none,
160
+ 3, 43, :_reduce_1,
161
+ 2, 44, :_reduce_none,
169
162
  4, 47, :_reduce_none,
170
- 2, 49, :_reduce_none,
163
+ 0, 47, :_reduce_none,
164
+ 2, 45, :_reduce_5,
165
+ 0, 45, :_reduce_6,
166
+ 20, 48, :_reduce_7,
167
+ 3, 49, :_reduce_none,
171
168
  0, 49, :_reduce_none,
172
- 9, 50, :_reduce_none,
173
- 0, 50, :_reduce_none,
174
- 14, 52, :_reduce_none,
175
- 0, 52, :_reduce_none,
176
- 18, 51, :_reduce_none,
177
- 3, 51, :_reduce_none,
178
- 3, 51, :_reduce_none,
179
- 3, 51, :_reduce_none,
180
- 3, 51, :_reduce_none,
181
- 3, 51, :_reduce_none,
169
+ 2, 50, :_reduce_none,
170
+ 1, 50, :_reduce_none,
171
+ 5, 48, :_reduce_none,
172
+ 4, 48, :_reduce_none,
173
+ 2, 51, :_reduce_none,
182
174
  0, 51, :_reduce_none,
183
- 1, 53, :_reduce_none,
184
- 1, 53, :_reduce_none,
185
- 1, 53, :_reduce_none,
186
- 1, 53, :_reduce_none,
187
- 2, 45, :_reduce_none,
188
- 2, 45, :_reduce_none,
189
- 2, 54, :_reduce_none,
190
- 1, 54, :_reduce_none ]
191
-
192
- racc_reduce_n = 33
193
-
194
- racc_shift_n = 101
175
+ 9, 52, :_reduce_none,
176
+ 0, 52, :_reduce_none,
177
+ 14, 54, :_reduce_none,
178
+ 0, 54, :_reduce_none,
179
+ 18, 53, :_reduce_none,
180
+ 3, 53, :_reduce_none,
181
+ 3, 53, :_reduce_none,
182
+ 3, 53, :_reduce_none,
183
+ 3, 53, :_reduce_none,
184
+ 3, 53, :_reduce_none,
185
+ 0, 53, :_reduce_none,
186
+ 1, 55, :_reduce_none,
187
+ 1, 55, :_reduce_none,
188
+ 1, 55, :_reduce_none,
189
+ 1, 55, :_reduce_none,
190
+ 2, 46, :_reduce_none,
191
+ 2, 46, :_reduce_none,
192
+ 2, 56, :_reduce_none,
193
+ 1, 56, :_reduce_none ]
194
+
195
+ racc_reduce_n = 35
196
+
197
+ racc_shift_n = 105
195
198
 
196
199
  racc_token_table = {
197
200
  false => 0,
198
201
  :error => 1,
199
202
  :ALGORITHM => 2,
200
- :BITMAP => 3,
201
- :BLOCKS => 4,
202
- :BYTE_UNIT => 5,
203
- :CHECK => 6,
204
- :CHUNK => 7,
205
- :DELAYED => 8,
206
- :DISK_STATUS => 9,
207
- :FINISH => 10,
208
- :FLOAT => 11,
209
- :IDENTIFIER => 12,
210
- :INTEGER => 13,
211
- :LEVEL => 14,
212
- :MIN => 15,
213
- :NONE => 16,
214
- :PAGES => 17,
215
- :PERSONALITIES => 18,
216
- :PERSONALITY => 19,
217
- :PENDING => 20,
218
- :PROGRESS => 21,
219
- :RECOVER => 22,
220
- :RECOVERY => 23,
221
- :REMOTE => 24,
222
- :RESHAPE => 25,
223
- :RESYNC => 26,
224
- :SPEED => 27,
225
- :SPEED_UNIT => 28,
226
- :SUPER => 29,
227
- :UNIT => 30,
228
- :UNUSED_DEVICES => 31,
229
- "[" => 32,
230
- "]" => 33,
231
- ":" => 34,
232
- "/" => 35,
233
- "," => 36,
234
- "=" => 37,
235
- "%" => 38,
236
- "(" => 39,
237
- ")" => 40 }
238
-
239
- racc_nt_base = 41
203
+ :AUTO_READ_ONLY => 3,
204
+ :BITMAP => 4,
205
+ :BLOCKS => 5,
206
+ :BYTE_UNIT => 6,
207
+ :CHECK => 7,
208
+ :CHUNK => 8,
209
+ :DELAYED => 9,
210
+ :DISK_STATUS => 10,
211
+ :FINISH => 11,
212
+ :FLOAT => 12,
213
+ :IDENTIFIER => 13,
214
+ :INTEGER => 14,
215
+ :LEVEL => 15,
216
+ :MIN => 16,
217
+ :NONE => 17,
218
+ :PAGES => 18,
219
+ :PERSONALITIES => 19,
220
+ :PERSONALITY => 20,
221
+ :PENDING => 21,
222
+ :PROGRESS => 22,
223
+ :RECOVER => 23,
224
+ :RECOVERY => 24,
225
+ :REMOTE => 25,
226
+ :RESHAPE => 26,
227
+ :RESYNC => 27,
228
+ :SPEED => 28,
229
+ :SPEED_UNIT => 29,
230
+ :SUPER => 30,
231
+ :UNIT => 31,
232
+ :UNUSED_DEVICES => 32,
233
+ "[" => 33,
234
+ "]" => 34,
235
+ ":" => 35,
236
+ "/" => 36,
237
+ "(" => 37,
238
+ ")" => 38,
239
+ "," => 39,
240
+ "=" => 40,
241
+ "%" => 41 }
242
+
243
+ racc_nt_base = 42
240
244
 
241
245
  racc_use_result_var = true
242
246
 
@@ -261,6 +265,7 @@ Racc_token_to_s_table = [
261
265
  "$end",
262
266
  "error",
263
267
  "ALGORITHM",
268
+ "AUTO_READ_ONLY",
264
269
  "BITMAP",
265
270
  "BLOCKS",
266
271
  "BYTE_UNIT",
@@ -294,11 +299,11 @@ Racc_token_to_s_table = [
294
299
  "\"]\"",
295
300
  "\":\"",
296
301
  "\"/\"",
302
+ "\"(\"",
303
+ "\")\"",
297
304
  "\",\"",
298
305
  "\"=\"",
299
306
  "\"%\"",
300
- "\"(\"",
301
- "\")\"",
302
307
  "$start",
303
308
  "target",
304
309
  "personalities",
@@ -306,6 +311,7 @@ Racc_token_to_s_table = [
306
311
  "unused_devices",
307
312
  "list_of_personalities",
308
313
  "device",
314
+ "auto_read_only",
309
315
  "list_of_devices",
310
316
  "super",
311
317
  "level",
@@ -350,7 +356,7 @@ module_eval(<<'.,.,', 'mdstat_parser.y', 11)
350
356
 
351
357
  module_eval(<<'.,.,', 'mdstat_parser.y', 13)
352
358
  def _reduce_7(val, _values, result)
353
- result = { val[0][:value] => val[15][:value] }
359
+ result = { val[0][:value] => val[16][:value] }
354
360
  result
355
361
  end
356
362
  .,.,
@@ -405,6 +411,10 @@ module_eval(<<'.,.,', 'mdstat_parser.y', 13)
405
411
 
406
412
  # reduce 32 omitted
407
413
 
414
+ # reduce 33 omitted
415
+
416
+ # reduce 34 omitted
417
+
408
418
  def _reduce_none(val, _values, result)
409
419
  val[0]
410
420
  end
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Tools
8
8
  class Memcached
9
9
  include Riemann::Tools
10
+
10
11
  require 'socket'
11
12
 
12
13
  opt :memcached_host, 'Memcached hostname', default: 'localhost'
@@ -9,6 +9,7 @@ module Riemann
9
9
  module Tools
10
10
  class NginxStatus
11
11
  include Riemann::Tools
12
+
12
13
  require 'net/http'
13
14
  require 'uri'
14
15
 
@@ -8,6 +8,7 @@ module Riemann
8
8
  module Tools
9
9
  class Portcheck
10
10
  include Riemann::Tools
11
+
11
12
  require 'socket'
12
13
 
13
14
  opt :hostname, 'Host, defaults to localhost', default: `hostname`.chomp
@@ -7,18 +7,49 @@ require 'riemann/client'
7
7
  module Riemann
8
8
  module Tools
9
9
  class RiemannClientWrapper
10
- attr_reader :options
10
+ include Singleton
11
11
 
12
12
  BACKOFF_TMIN = 0.5 # Minimum delay between reconnection attempts
13
13
  BACKOFF_TMAX = 30.0 # Maximum delay
14
14
  BACKOFF_FACTOR = 2
15
15
 
16
- def initialize(options)
17
- @options = options
16
+ # The wrapper manage a single connection to riemann, transport options
17
+ # cannot be adjusted when riemann-wrapper is running, and enqueing events
18
+ # should not happen when the system is tearing down. This is achieved
19
+ # with this simple state machine
20
+ #
21
+ # [idle] --client--> [running] --drain--> [draining]
22
+ # ^ |
23
+ # +-------[#reset (development only)]-------+
24
+ attr_reader :state
25
+
26
+ STATE_IDLE = 1
27
+ STATE_RUNNING = 2
28
+ STATE_DRAINING = 3
29
+
30
+ # These options are transport-related, and SHALL be the same for each
31
+ # tool running in riemann-wrapper. Other options are ignored as far as
32
+ # the wrapper is concerned.
33
+ ALLOWED_OPTIONS = %i[host port timeout tls tls_key tls_cert tls_ca_cert tls_verify tcp tls].freeze
34
+
35
+ attr_reader :options
36
+
37
+ def options=(options)
38
+ if state == STATE_IDLE
39
+ @options = options
40
+ @client = nil
41
+ else
42
+ return if options.slice(*ALLOWED_OPTIONS) == @options.slice(*ALLOWED_OPTIONS)
18
43
 
44
+ raise 'Cannot change options while running'
45
+ end
46
+ end
47
+
48
+ def initialize
49
+ @options = nil
19
50
  @queue = Queue.new
20
51
  @max_bulk_size = 1000
21
- @draining = false
52
+ @state = STATE_IDLE
22
53
 
23
54
  @worker = Thread.new do
24
55
  Thread.current.abort_on_exception = true
@@ -49,6 +80,8 @@ module Riemann
49
80
 
50
81
  def client
51
82
  @client ||= begin
83
+ @state = STATE_RUNNING
84
+
52
85
  r = Riemann::Client.new(
53
86
  host: options[:host],
54
87
  port: options[:port],
@@ -69,15 +102,25 @@ module Riemann
69
102
  end
70
103
 
71
104
  def <<(event)
72
- raise('Cannot queue events when draining') if @draining
105
+ raise('Cannot queue events while draining') if state == STATE_DRAINING
73
106
 
74
107
  @queue << event
75
108
  end
76
109
 
77
110
  def drain
78
- @draining = true
111
+ @state = STATE_DRAINING
79
112
  sleep(1) until @queue.empty? || @worker.stop?
80
113
  end
114
+
115
+ private
116
+
117
+ # For development purpose only: we do not want the singleton to leak
118
+ # state from one test to another.
119
+ def reset
120
+ @options = nil
121
+ @queue.clear
122
+ @state = STATE_IDLE
123
+ end
81
124
  end
82
125
  end
83
126
  end
@@ -24,7 +24,7 @@ module URI
24
24
  end
25
25
  end
26
26
 
27
- module Riemann
27
+ module Riemann # rubocop:disable Style/OneClassPerFile
28
28
  module Tools
29
29
  class TLSCheck
30
30
  include Riemann::Tools
@@ -202,6 +202,8 @@ module Riemann
202
202
  description.start_with? 'OCSP'
203
203
  end
204
204
 
205
+ return '' unless ocsp
206
+
205
207
  ocsp_uri = URI(ocsp[/URI:(.*)/, 1])
206
208
 
207
209
  http_response = ::Net::HTTP.start(ocsp_uri.hostname, ocsp_uri.port) do |http|
@@ -478,7 +480,7 @@ module Riemann
478
480
  capabilities = initial_handshake_packet[5] | (initial_handshake_packet[8] << 16)
479
481
 
480
482
  ssl_flag = 1 << 11
481
- raise 'No TLS support' if (capabilities & ssl_flag).zero?
483
+ raise 'No TLS support' if capabilities.nobits?(ssl_flag)
482
484
 
483
485
  socket.write(['2000000185ae7f0000000001210000000000000000000000000000000000000000000000'].pack('H*'))
484
486
  tls_handshake(socket, uri.host)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.6.0
3
+ # This file is automatically generated by Racc 1.6.2
4
4
  # from Racc grammar file "".
5
5
  #
6
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
- VERSION = '1.11.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Tools
8
8
  class Zookeeper
9
9
  include Riemann::Tools
10
+
10
11
  require 'socket'
11
12
 
12
13
  opt :zookeeper_host, 'Zookeeper hostname', default: 'localhost'
data/lib/riemann/tools.rb CHANGED
@@ -82,7 +82,10 @@ module Riemann
82
82
  end
83
83
 
84
84
  def riemann
85
- @riemann ||= RiemannClientWrapper.new(options)
85
+ @riemann ||= begin
86
+ RiemannClientWrapper.instance.options = options
87
+ RiemannClientWrapper.instance
88
+ end
86
89
  end
87
90
  alias r riemann
88
91
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Collection of utilities which submit events to Riemann,'
13
13
  spec.homepage = 'https://github.com/aphyr/riemann-tools'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
16
16
 
17
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
18
18
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -38,7 +38,8 @@ Gem::Specification.new do |spec|
38
38
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
39
39
  spec.require_paths = ['lib']
40
40
 
41
- spec.add_runtime_dependency 'json', '>= 1.8'
42
- spec.add_runtime_dependency 'optimist', '~> 3.0', '>= 3.0.0'
43
- spec.add_runtime_dependency 'riemann-client', '~> 1.1'
41
+ spec.add_dependency 'csv', '~> 3.0'
42
+ spec.add_dependency 'json', '>= 1.8'
43
+ spec.add_dependency 'optimist', '~> 3.0', '>= 3.0.0'
44
+ spec.add_dependency 'riemann-client', '~> 1.1'
44
45
  end
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class Billing
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
 
12
13
  opt :fog_credentials_file, 'Fog credentials file', type: String
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class ElbMetrics
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class RdsStatus
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'date'
12
13
  require 'time'
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class S3List
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class S3Status
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'time'
12
13
 
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class SqsStatus
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
 
12
13
  opt :access_key, 'AWS access key', type: String
@@ -7,6 +7,7 @@ module Riemann
7
7
  module Aws
8
8
  class Status
9
9
  include Riemann::Tools
10
+
10
11
  require 'fog/aws'
11
12
  require 'date'
12
13
 
@@ -49,15 +49,15 @@ module Riemann
49
49
  def health_url
50
50
  path_prefix = options[:path_prefix]
51
51
  path_prefix[0] = '' if path_prefix[0] == '/'
52
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
53
- "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/metrics"
52
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
53
+ "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/metrics"
54
54
  end
55
55
 
56
56
  def jobs_url
57
57
  path_prefix = options[:path_prefix]
58
58
  path_prefix[0] = '' if path_prefix[0] == '/'
59
- path_prefix[path_prefix.length - 1] = '' if path_prefix[path_prefix.length - 1] == '/'
60
- "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{path_prefix.length.positive? ? '/' : ''}#{path_prefix}/scheduler/jobs"
59
+ path_prefix[-1] = '' if path_prefix[-1] == '/'
60
+ "http://#{options[:chronos_host]}:#{options[:chronos_port]}#{'/' if path_prefix.length.positive?}#{path_prefix}/scheduler/jobs"
61
61
  end
62
62
 
63
63
  def tick