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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +25 -2
- data/Rakefile +10 -3
- data/bin/riemann-apache-status +1 -106
- data/bin/riemann-bench +2 -70
- data/bin/riemann-cloudant +1 -56
- data/bin/riemann-consul +1 -106
- data/bin/riemann-dir-files-count +1 -55
- data/bin/riemann-dir-space +1 -55
- data/bin/riemann-diskstats +1 -92
- data/bin/riemann-fd +2 -81
- data/bin/riemann-freeswitch +2 -119
- data/bin/riemann-haproxy +1 -58
- data/bin/riemann-health +0 -2
- data/bin/riemann-kvminstance +2 -22
- data/bin/riemann-memcached +1 -37
- data/bin/riemann-net +0 -2
- data/bin/riemann-nginx-status +1 -85
- data/bin/riemann-ntp +0 -2
- data/bin/riemann-portcheck +1 -44
- data/bin/riemann-proc +1 -108
- data/bin/riemann-varnish +1 -54
- data/bin/riemann-wrapper +75 -0
- data/bin/riemann-zookeeper +1 -39
- data/lib/riemann/tools/apache_status.rb +107 -0
- data/lib/riemann/tools/bench.rb +72 -0
- data/lib/riemann/tools/cloudant.rb +57 -0
- data/lib/riemann/tools/consul_health.rb +107 -0
- data/lib/riemann/tools/dir_files_count.rb +56 -0
- data/lib/riemann/tools/dir_space.rb +56 -0
- data/lib/riemann/tools/diskstats.rb +94 -0
- data/lib/riemann/tools/fd.rb +81 -0
- data/lib/riemann/tools/freeswitch.rb +119 -0
- data/lib/riemann/tools/haproxy.rb +59 -0
- data/lib/riemann/tools/health.rb +150 -19
- data/lib/riemann/tools/kvm.rb +23 -0
- data/lib/riemann/tools/memcached.rb +38 -0
- data/lib/riemann/tools/net.rb +2 -1
- data/lib/riemann/tools/nginx_status.rb +86 -0
- data/lib/riemann/tools/ntp.rb +1 -0
- data/lib/riemann/tools/portcheck.rb +45 -0
- data/lib/riemann/tools/proc.rb +109 -0
- data/lib/riemann/tools/riemann_client_wrapper.rb +43 -0
- data/lib/riemann/tools/uptime_parser.tab.rb +323 -0
- data/lib/riemann/tools/varnish.rb +55 -0
- data/lib/riemann/tools/version.rb +1 -1
- data/lib/riemann/tools/zookeeper.rb +40 -0
- data/lib/riemann/tools.rb +2 -20
- data/riemann-tools.gemspec +4 -1
- data/tools/riemann-aws/Rakefile +6 -9
- data/tools/riemann-aws/bin/riemann-aws-billing +2 -87
- data/tools/riemann-aws/bin/riemann-aws-rds-status +2 -62
- data/tools/riemann-aws/bin/riemann-aws-sqs-status +2 -44
- data/tools/riemann-aws/bin/riemann-aws-status +2 -77
- data/tools/riemann-aws/bin/riemann-elb-metrics +2 -162
- data/tools/riemann-aws/bin/riemann-s3-list +2 -81
- data/tools/riemann-aws/bin/riemann-s3-status +2 -96
- data/tools/riemann-aws/lib/riemann/tools/aws/billing.rb +87 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/elb_metrics.rb +163 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/rds_status.rb +63 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_list.rb +82 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/s3_status.rb +97 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb +45 -0
- data/tools/riemann-aws/lib/riemann/tools/aws/status.rb +74 -0
- data/tools/riemann-chronos/Rakefile +6 -9
- data/tools/riemann-chronos/bin/riemann-chronos +1 -154
- data/tools/riemann-chronos/lib/riemann/tools/chronos.rb +157 -0
- data/tools/riemann-docker/Rakefile +5 -8
- data/tools/riemann-docker/bin/riemann-docker +2 -200
- data/tools/riemann-docker/lib/riemann/tools/docker.rb +200 -0
- data/tools/riemann-elasticsearch/Rakefile +6 -9
- data/tools/riemann-elasticsearch/bin/riemann-elasticsearch +1 -167
- data/tools/riemann-elasticsearch/lib/riemann/tools/elasticsearch.rb +170 -0
- data/tools/riemann-marathon/Rakefile +6 -9
- data/tools/riemann-marathon/bin/riemann-marathon +1 -156
- data/tools/riemann-marathon/lib/riemann/tools/marathon.rb +159 -0
- data/tools/riemann-mesos/Rakefile +6 -9
- data/tools/riemann-mesos/bin/riemann-mesos +1 -139
- data/tools/riemann-mesos/lib/riemann/tools/mesos.rb +142 -0
- data/tools/riemann-munin/Rakefile +5 -8
- data/tools/riemann-munin/bin/riemann-munin +1 -36
- data/tools/riemann-munin/lib/riemann/tools/munin.rb +37 -0
- data/tools/riemann-rabbitmq/Rakefile +6 -9
- data/tools/riemann-rabbitmq/bin/riemann-rabbitmq +1 -266
- data/tools/riemann-rabbitmq/lib/riemann/tools/rabbitmq.rb +269 -0
- data/tools/riemann-riak/Rakefile +5 -8
- data/tools/riemann-riak/bin/riemann-riak +1 -316
- data/tools/riemann-riak/bin/riemann-riak-keys +0 -1
- data/tools/riemann-riak/bin/riemann-riak-ring +0 -1
- data/tools/riemann-riak/lib/riemann/tools/riak.rb +317 -0
- metadata +57 -10
- data/.travis.yml +0 -31
- data/tools/riemann-riak/riak_status/key_count.erl +0 -13
- data/tools/riemann-riak/riak_status/riak_status.rb +0 -152
- data/tools/riemann-riak/riak_status/ringready.erl +0 -9
@@ -0,0 +1,323 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.6.0
|
4
|
+
# from Racc grammar file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
|
10
|
+
require 'strscan'
|
11
|
+
|
12
|
+
module Riemann
|
13
|
+
module Tools
|
14
|
+
class UptimeParser < Racc::Parser
|
15
|
+
|
16
|
+
module_eval(<<'...end uptime_parser.y/module_eval...', 'uptime_parser.y', 43)
|
17
|
+
|
18
|
+
def parse(text)
|
19
|
+
s = StringScanner.new(text)
|
20
|
+
@tokens = []
|
21
|
+
|
22
|
+
until s.eos? do
|
23
|
+
case
|
24
|
+
when s.scan(/\n/) then # ignore
|
25
|
+
when s.scan(/\s+/) then # ignore
|
26
|
+
|
27
|
+
when s.scan(/:/) then @tokens << [':', s.matched]
|
28
|
+
when s.scan(/,/) then @tokens << [',', s.matched]
|
29
|
+
when s.scan(/\d+[,.]\d+/) then @tokens << [:FLOAT, s.matched.sub(',', '.').to_f]
|
30
|
+
when s.scan(/\d+/) then @tokens << [:INTEGER, s.matched.to_i]
|
31
|
+
when s.scan(/AM/) then @tokens << [:AM, s.matched]
|
32
|
+
when s.scan(/PM/) then @tokens << [:PM, s.matched]
|
33
|
+
when s.scan(/up/) then @tokens << [:UP, s.matched]
|
34
|
+
when s.scan(/days?/) then @tokens << [:DAYS, s.matched]
|
35
|
+
when s.scan(/hrs?/) then @tokens << [:HRS, s.matched]
|
36
|
+
when s.scan(/mins?/) then @tokens << [:MINS, s.matched]
|
37
|
+
when s.scan(/secs?/) then @tokens << [:SECS, s.matched]
|
38
|
+
when s.scan(/users?/) then @tokens << [:USERS, s.matched]
|
39
|
+
when s.scan(/load averages?:/) then @tokens << [:LOAD_AVERAGES, s.matched]
|
40
|
+
else
|
41
|
+
raise s.rest
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
do_parse
|
46
|
+
end
|
47
|
+
|
48
|
+
def next_token
|
49
|
+
@tokens.shift
|
50
|
+
end
|
51
|
+
...end uptime_parser.y/module_eval...
|
52
|
+
##### State transition tables begin ###
|
53
|
+
|
54
|
+
racc_action_table = [
|
55
|
+
29, 30, 24, 26, 27, 28, 26, 27, 28, 40,
|
56
|
+
41, 25, 31, 3, 25, 4, 6, 7, 8, 9,
|
57
|
+
15, 16, 18, 23, 32, 33, 34, 35, 36, 38,
|
58
|
+
39, 42, 43, 44, 45 ]
|
59
|
+
|
60
|
+
racc_action_check = [
|
61
|
+
16, 16, 15, 15, 15, 15, 23, 23, 23, 39,
|
62
|
+
39, 15, 16, 0, 23, 1, 2, 3, 4, 5,
|
63
|
+
6, 7, 9, 10, 17, 18, 24, 25, 31, 32,
|
64
|
+
38, 40, 41, 43, 44 ]
|
65
|
+
|
66
|
+
racc_action_pointer = [
|
67
|
+
2, 15, 12, 3, 18, 6, 9, 10, nil, 11,
|
68
|
+
12, nil, nil, nil, nil, -3, -2, 11, 16, nil,
|
69
|
+
nil, nil, nil, 0, 13, 16, nil, nil, nil, nil,
|
70
|
+
nil, 17, 19, nil, nil, nil, nil, nil, 18, -3,
|
71
|
+
19, 20, nil, 20, 22, nil ]
|
72
|
+
|
73
|
+
racc_action_default = [
|
74
|
+
-22, -22, -22, -22, -22, -22, -22, -22, 46, -22,
|
75
|
+
-22, -10, -11, -12, -13, -22, -2, -22, -22, -6,
|
76
|
+
-7, -8, -9, -22, -22, -22, -16, -17, -18, -3,
|
77
|
+
-4, -22, -22, -19, -14, -15, -5, -1, -22, -22,
|
78
|
+
-22, -22, -20, -22, -22, -21 ]
|
79
|
+
|
80
|
+
racc_goto_table = [
|
81
|
+
11, 12, 13, 14, 19, 20, 21, 22, 1, 2,
|
82
|
+
5, 17, 37, 10 ]
|
83
|
+
|
84
|
+
racc_goto_check = [
|
85
|
+
7, 8, 9, 10, 7, 8, 9, 10, 1, 2,
|
86
|
+
3, 4, 5, 6 ]
|
87
|
+
|
88
|
+
racc_goto_pointer = [
|
89
|
+
nil, 8, 9, 8, 2, -20, 7, -6, -5, -4,
|
90
|
+
-3 ]
|
91
|
+
|
92
|
+
racc_goto_default = [
|
93
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
94
|
+
nil ]
|
95
|
+
|
96
|
+
racc_reduce_table = [
|
97
|
+
0, 0, :racc_error,
|
98
|
+
6, 16, :_reduce_1,
|
99
|
+
3, 17, :_reduce_none,
|
100
|
+
4, 17, :_reduce_none,
|
101
|
+
4, 17, :_reduce_none,
|
102
|
+
5, 17, :_reduce_none,
|
103
|
+
3, 18, :_reduce_6,
|
104
|
+
3, 18, :_reduce_7,
|
105
|
+
3, 18, :_reduce_8,
|
106
|
+
3, 18, :_reduce_9,
|
107
|
+
2, 18, :_reduce_10,
|
108
|
+
2, 18, :_reduce_11,
|
109
|
+
2, 18, :_reduce_12,
|
110
|
+
2, 18, :_reduce_13,
|
111
|
+
3, 21, :_reduce_14,
|
112
|
+
3, 22, :_reduce_15,
|
113
|
+
2, 23, :_reduce_16,
|
114
|
+
2, 24, :_reduce_17,
|
115
|
+
2, 25, :_reduce_18,
|
116
|
+
2, 19, :_reduce_none,
|
117
|
+
4, 20, :_reduce_20,
|
118
|
+
6, 20, :_reduce_21 ]
|
119
|
+
|
120
|
+
racc_reduce_n = 22
|
121
|
+
|
122
|
+
racc_shift_n = 46
|
123
|
+
|
124
|
+
racc_token_table = {
|
125
|
+
false => 0,
|
126
|
+
:error => 1,
|
127
|
+
:AM => 2,
|
128
|
+
:PM => 3,
|
129
|
+
:UP => 4,
|
130
|
+
:DAYS => 5,
|
131
|
+
:HRS => 6,
|
132
|
+
:MINS => 7,
|
133
|
+
:SECS => 8,
|
134
|
+
:USERS => 9,
|
135
|
+
:LOAD_AVERAGES => 10,
|
136
|
+
:INTEGER => 11,
|
137
|
+
:FLOAT => 12,
|
138
|
+
"," => 13,
|
139
|
+
":" => 14 }
|
140
|
+
|
141
|
+
racc_nt_base = 15
|
142
|
+
|
143
|
+
racc_use_result_var = true
|
144
|
+
|
145
|
+
Racc_arg = [
|
146
|
+
racc_action_table,
|
147
|
+
racc_action_check,
|
148
|
+
racc_action_default,
|
149
|
+
racc_action_pointer,
|
150
|
+
racc_goto_table,
|
151
|
+
racc_goto_check,
|
152
|
+
racc_goto_default,
|
153
|
+
racc_goto_pointer,
|
154
|
+
racc_nt_base,
|
155
|
+
racc_reduce_table,
|
156
|
+
racc_token_table,
|
157
|
+
racc_shift_n,
|
158
|
+
racc_reduce_n,
|
159
|
+
racc_use_result_var ]
|
160
|
+
|
161
|
+
Racc_token_to_s_table = [
|
162
|
+
"$end",
|
163
|
+
"error",
|
164
|
+
"AM",
|
165
|
+
"PM",
|
166
|
+
"UP",
|
167
|
+
"DAYS",
|
168
|
+
"HRS",
|
169
|
+
"MINS",
|
170
|
+
"SECS",
|
171
|
+
"USERS",
|
172
|
+
"LOAD_AVERAGES",
|
173
|
+
"INTEGER",
|
174
|
+
"FLOAT",
|
175
|
+
"\",\"",
|
176
|
+
"\":\"",
|
177
|
+
"$start",
|
178
|
+
"target",
|
179
|
+
"time",
|
180
|
+
"uptime",
|
181
|
+
"users",
|
182
|
+
"load_averages",
|
183
|
+
"uptime_days",
|
184
|
+
"uptime_hr_min",
|
185
|
+
"uptime_hr",
|
186
|
+
"uptime_min",
|
187
|
+
"uptime_sec" ]
|
188
|
+
|
189
|
+
Racc_debug_parser = false
|
190
|
+
|
191
|
+
##### State transition tables end #####
|
192
|
+
|
193
|
+
# reduce 0 omitted
|
194
|
+
|
195
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 4)
|
196
|
+
def _reduce_1(val, _values, result)
|
197
|
+
result = { uptime: val[1], users: val[3], load_averages: val[5] }
|
198
|
+
result
|
199
|
+
end
|
200
|
+
.,.,
|
201
|
+
|
202
|
+
# reduce 2 omitted
|
203
|
+
|
204
|
+
# reduce 3 omitted
|
205
|
+
|
206
|
+
# reduce 4 omitted
|
207
|
+
|
208
|
+
# reduce 5 omitted
|
209
|
+
|
210
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 11)
|
211
|
+
def _reduce_6(val, _values, result)
|
212
|
+
result = val[1] + val[2]
|
213
|
+
result
|
214
|
+
end
|
215
|
+
.,.,
|
216
|
+
|
217
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 12)
|
218
|
+
def _reduce_7(val, _values, result)
|
219
|
+
result = val[1] + val[2]
|
220
|
+
result
|
221
|
+
end
|
222
|
+
.,.,
|
223
|
+
|
224
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 13)
|
225
|
+
def _reduce_8(val, _values, result)
|
226
|
+
result = val[1] + val[2]
|
227
|
+
result
|
228
|
+
end
|
229
|
+
.,.,
|
230
|
+
|
231
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 14)
|
232
|
+
def _reduce_9(val, _values, result)
|
233
|
+
result = val[1] + val[2]
|
234
|
+
result
|
235
|
+
end
|
236
|
+
.,.,
|
237
|
+
|
238
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 15)
|
239
|
+
def _reduce_10(val, _values, result)
|
240
|
+
result = val[1]
|
241
|
+
result
|
242
|
+
end
|
243
|
+
.,.,
|
244
|
+
|
245
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 16)
|
246
|
+
def _reduce_11(val, _values, result)
|
247
|
+
result = val[1]
|
248
|
+
result
|
249
|
+
end
|
250
|
+
.,.,
|
251
|
+
|
252
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 17)
|
253
|
+
def _reduce_12(val, _values, result)
|
254
|
+
result = val[1]
|
255
|
+
result
|
256
|
+
end
|
257
|
+
.,.,
|
258
|
+
|
259
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 18)
|
260
|
+
def _reduce_13(val, _values, result)
|
261
|
+
result = val[1]
|
262
|
+
result
|
263
|
+
end
|
264
|
+
.,.,
|
265
|
+
|
266
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 20)
|
267
|
+
def _reduce_14(val, _values, result)
|
268
|
+
result = val[0] * 86400
|
269
|
+
result
|
270
|
+
end
|
271
|
+
.,.,
|
272
|
+
|
273
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 22)
|
274
|
+
def _reduce_15(val, _values, result)
|
275
|
+
result = val[0] * 3600 + val[2] * 60
|
276
|
+
result
|
277
|
+
end
|
278
|
+
.,.,
|
279
|
+
|
280
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 24)
|
281
|
+
def _reduce_16(val, _values, result)
|
282
|
+
result = val[0] * 3600
|
283
|
+
result
|
284
|
+
end
|
285
|
+
.,.,
|
286
|
+
|
287
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 26)
|
288
|
+
def _reduce_17(val, _values, result)
|
289
|
+
result = val[0] * 60
|
290
|
+
result
|
291
|
+
end
|
292
|
+
.,.,
|
293
|
+
|
294
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 28)
|
295
|
+
def _reduce_18(val, _values, result)
|
296
|
+
result = val[0]
|
297
|
+
result
|
298
|
+
end
|
299
|
+
.,.,
|
300
|
+
|
301
|
+
# reduce 19 omitted
|
302
|
+
|
303
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 32)
|
304
|
+
def _reduce_20(val, _values, result)
|
305
|
+
result = { 1 => val[1], 5 => val[2], 15 => val[3] }
|
306
|
+
result
|
307
|
+
end
|
308
|
+
.,.,
|
309
|
+
|
310
|
+
module_eval(<<'.,.,', 'uptime_parser.y', 33)
|
311
|
+
def _reduce_21(val, _values, result)
|
312
|
+
result = { 1 => val[1], 5 => val[3], 15 => val[5] }
|
313
|
+
result
|
314
|
+
end
|
315
|
+
.,.,
|
316
|
+
|
317
|
+
def _reduce_none(val, _values, result)
|
318
|
+
val[0]
|
319
|
+
end
|
320
|
+
|
321
|
+
end # class UptimeParser
|
322
|
+
end # module Tools
|
323
|
+
end # module Riemann
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require 'riemann/tools'
|
5
|
+
|
6
|
+
# Reports varnish stats to Riemann.
|
7
|
+
module Riemann
|
8
|
+
module Tools
|
9
|
+
class Varnish
|
10
|
+
include Riemann::Tools
|
11
|
+
|
12
|
+
opt :varnish_host, 'Varnish hostname', default: `hostname`.chomp
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
cmd = 'varnishstat -V'
|
16
|
+
Open3.popen3(cmd) do |_stdin, _stdout, stderr, _wait_thr|
|
17
|
+
@ver = /varnishstat \(varnish-(\d+)/.match(stderr.read)[1].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
@vstats = if @ver >= 4
|
21
|
+
['MAIN.sess_conn',
|
22
|
+
'MAIN.sess_drop ',
|
23
|
+
'MAIN.client_req',
|
24
|
+
'MAIN.cache_hit',
|
25
|
+
'MAIN.cache_miss',]
|
26
|
+
else
|
27
|
+
%w[client_conn
|
28
|
+
client_drop
|
29
|
+
client_req
|
30
|
+
cache_hit
|
31
|
+
cache_miss]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def tick
|
36
|
+
stats = if @ver >= 4
|
37
|
+
`varnishstat -1 -f #{@vstats.join(' -f ')}`
|
38
|
+
else
|
39
|
+
`varnishstat -1 -f #{@vstats.join(',')}`
|
40
|
+
end
|
41
|
+
stats.each_line do |stat|
|
42
|
+
m = stat.split
|
43
|
+
report(
|
44
|
+
host: opts[:varnish_host].dup,
|
45
|
+
service: "varnish #{m[0]}",
|
46
|
+
metric: m[1].to_f,
|
47
|
+
state: 'ok',
|
48
|
+
description: m[3..].join(' ').to_s,
|
49
|
+
tags: ['varnish'],
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
# Gathers zookeeper STATS and submits them to Riemann.
|
6
|
+
module Riemann
|
7
|
+
module Tools
|
8
|
+
class Zookeeper
|
9
|
+
include Riemann::Tools
|
10
|
+
require 'socket'
|
11
|
+
|
12
|
+
opt :zookeeper_host, 'Zookeeper hostname', default: 'localhost'
|
13
|
+
opt :zookeeper_port, 'Zookeeper port', default: 2181
|
14
|
+
|
15
|
+
def tick
|
16
|
+
sock = TCPSocket.new(opts[:zookeeper_host], opts[:zookeeper_port])
|
17
|
+
sock.sync = true
|
18
|
+
sock.print('mntr')
|
19
|
+
sock.flush
|
20
|
+
|
21
|
+
loop do
|
22
|
+
stats = sock.gets
|
23
|
+
|
24
|
+
break if stats.nil?
|
25
|
+
|
26
|
+
m = stats.match(/^(\w+)\t+(.*)/)
|
27
|
+
|
28
|
+
report(
|
29
|
+
host: opts[:zookeeper_host].dup,
|
30
|
+
service: "zookeeper #{m[1]}",
|
31
|
+
metric: m[2].to_f,
|
32
|
+
state: 'ok',
|
33
|
+
tags: ['zookeeper'],
|
34
|
+
)
|
35
|
+
end
|
36
|
+
sock.close
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/riemann/tools.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Riemann
|
4
4
|
module Tools
|
5
5
|
require 'optimist'
|
6
|
-
require 'riemann/
|
6
|
+
require 'riemann/tools/riemann_client_wrapper'
|
7
7
|
|
8
8
|
def self.included(base)
|
9
9
|
base.instance_eval do
|
@@ -72,26 +72,8 @@ module Riemann
|
|
72
72
|
riemann << event
|
73
73
|
end
|
74
74
|
|
75
|
-
def new_riemann_client
|
76
|
-
r = Riemann::Client.new(
|
77
|
-
host: options[:host],
|
78
|
-
port: options[:port],
|
79
|
-
timeout: options[:timeout],
|
80
|
-
ssl: options[:tls],
|
81
|
-
key_file: options[:tls_key],
|
82
|
-
cert_file: options[:tls_cert],
|
83
|
-
ca_file: options[:tls_ca_cert],
|
84
|
-
ssl_verify: options[:tls_verify],
|
85
|
-
)
|
86
|
-
if options[:tcp] || options[:tls]
|
87
|
-
r.tcp
|
88
|
-
else
|
89
|
-
r
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
75
|
def riemann
|
94
|
-
@riemann ||=
|
76
|
+
@riemann ||= RiemannClientWrapper.instance.configure(options)
|
95
77
|
end
|
96
78
|
alias r riemann
|
97
79
|
|
data/riemann-tools.gemspec
CHANGED
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } -
|
27
|
+
['lib/riemann/tools/uptime_parser.y'] +
|
28
|
+
['lib/riemann/tools/uptime_parser.tab.rb']
|
27
29
|
end
|
28
30
|
spec.bindir = 'bin'
|
29
31
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -34,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
34
36
|
spec.add_runtime_dependency 'riemann-client', '~> 1.0'
|
35
37
|
|
36
38
|
spec.add_development_dependency 'github_changelog_generator'
|
39
|
+
spec.add_development_dependency 'racc'
|
37
40
|
spec.add_development_dependency 'rake'
|
38
41
|
spec.add_development_dependency 'rspec'
|
39
42
|
spec.add_development_dependency 'rubocop'
|
data/tools/riemann-aws/Rakefile
CHANGED
@@ -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-aws'
|
15
|
-
|
16
14
|
s.name = 'riemann-aws'
|
17
|
-
s.version = '0.1.
|
15
|
+
s.version = '0.1.5'
|
18
16
|
s.author = 'Kyle Kingsbury'
|
19
17
|
s.email = 'aphyr@aphyr.com'
|
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 AWS stats to riemann.'
|
23
21
|
s.license = 'MIT'
|
24
22
|
|
25
|
-
s.
|
26
|
-
s.
|
27
|
-
s.
|
23
|
+
s.add_runtime_dependency 'riemann-tools', '~> 1.0', '>= 1.1.1'
|
24
|
+
s.add_runtime_dependency 'fog-aws', '~> 3.14', '>= 3.14.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 = '>=
|
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,91 +3,6 @@
|
|
3
3
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
5
5
|
|
6
|
-
require 'riemann/tools'
|
6
|
+
require 'riemann/tools/aws/billing'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
module Riemann
|
11
|
-
module Tools
|
12
|
-
class AWSBilling
|
13
|
-
include Riemann::Tools
|
14
|
-
require 'fog'
|
15
|
-
|
16
|
-
opt :fog_credentials_file, 'Fog credentials file', type: String
|
17
|
-
opt :fog_credential, 'Fog credentials to use', type: String
|
18
|
-
|
19
|
-
opt :access_key, 'AWS access key', type: String
|
20
|
-
opt :secret_key, 'Secret access key', type: String
|
21
|
-
opt :services, 'AWS services: AmazonEC2 AmazonS3 AWSDataTransfer', type: :strings, multi: true,
|
22
|
-
default: %w[AmazonEC2 AmazonS3 AWSDataTransfer]
|
23
|
-
|
24
|
-
opt :time_start, 'Start time in seconds of the metrics period (2hrs ago default)', type: Integer,
|
25
|
-
default: 7200
|
26
|
-
opt :time_end, 'End time in seconds of the metrics period ', type: Integer, default: 60
|
27
|
-
|
28
|
-
def initialize
|
29
|
-
if options[:fog_credentials_file]
|
30
|
-
Fog.credentials_path = opts[:fog_credentials_file]
|
31
|
-
Fog.credential = opts[:fog_credential].to_sym
|
32
|
-
@cloudwatch = Fog::AWS::CloudWatch.new
|
33
|
-
else
|
34
|
-
creds = if opts.key?('secret_key') && opts.key?('access_key')
|
35
|
-
{
|
36
|
-
aws_secret_access_key: opts[:secret_key],
|
37
|
-
aws_access_key_id: opts[:access_key],
|
38
|
-
}
|
39
|
-
else
|
40
|
-
{ use_iam_profile: true }
|
41
|
-
end
|
42
|
-
@cloudwatch = Fog::AWS::CloudWatch.new(creds)
|
43
|
-
end
|
44
|
-
@start_time = (Time.now.utc - opts[:time_start]).iso8601
|
45
|
-
@end_time = (Time.now.utc - opts[:time_end]).iso8601
|
46
|
-
end
|
47
|
-
|
48
|
-
def tick
|
49
|
-
opts[:services].each do |service|
|
50
|
-
data = @cloudwatch.get_metric_statistics({
|
51
|
-
'Statistics' => ['Maximum'],
|
52
|
-
'StartTime' => @start_time,
|
53
|
-
'EndTime' => @end_time,
|
54
|
-
'Period' => 3600,
|
55
|
-
'Unit' => 'None',
|
56
|
-
'MetricName' => 'EstimatedCharges',
|
57
|
-
'Namespace' => 'AWS/Billing',
|
58
|
-
'Dimensions' => [
|
59
|
-
{
|
60
|
-
'Name' => 'ServiceName',
|
61
|
-
'Value' => service,
|
62
|
-
},
|
63
|
-
{
|
64
|
-
'Name' => 'Currency',
|
65
|
-
'Value' => 'USD',
|
66
|
-
},
|
67
|
-
],
|
68
|
-
}).body['GetMetricStatisticsResult']['Datapoints']
|
69
|
-
|
70
|
-
data.each do |metrics|
|
71
|
-
name = "AWScloudwatch.Billing.#{service}"
|
72
|
-
value = metrics['Maximum']
|
73
|
-
timestamp = metrics['Timestamp'].to_i
|
74
|
-
|
75
|
-
event = {
|
76
|
-
host: nil,
|
77
|
-
service: name,
|
78
|
-
time: timestamp,
|
79
|
-
description: "AWS Estimate Charges for #{service}",
|
80
|
-
tags: ['aws_billing'],
|
81
|
-
state: 'ok',
|
82
|
-
metric: value,
|
83
|
-
}
|
84
|
-
|
85
|
-
report event
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
Riemann::Tools::AWSBilling.run
|
8
|
+
Riemann::Tools::Aws::Billing.run
|
@@ -3,66 +3,6 @@
|
|
3
3
|
|
4
4
|
Process.setproctitle($PROGRAM_NAME)
|
5
5
|
|
6
|
-
require 'riemann/tools'
|
6
|
+
require 'riemann/tools/aws/rds_status'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
module Riemann
|
11
|
-
module Tools
|
12
|
-
class AWS
|
13
|
-
include Riemann::Tools
|
14
|
-
require 'fog'
|
15
|
-
require 'date'
|
16
|
-
require 'time'
|
17
|
-
require 'json'
|
18
|
-
|
19
|
-
opt :access_key, 'AWS access key', type: String
|
20
|
-
opt :secret_key, 'Secret access key', type: String
|
21
|
-
opt :region, 'AWS region', type: String, default: 'eu-west-1'
|
22
|
-
opt :dbinstance_identifier, 'DBInstanceIdentifier', type: String
|
23
|
-
def initialize
|
24
|
-
abort 'FATAL: specify a DB instance name, see --help for usage' unless opts[:dbinstance_identifier]
|
25
|
-
creds = if opts[:access_key] && opts[:secret_key]
|
26
|
-
{
|
27
|
-
aws_access_key_id: opts[:access_key],
|
28
|
-
aws_secret_access_key: opts[:secret_key],
|
29
|
-
}
|
30
|
-
else
|
31
|
-
{ use_iam_profile: true }
|
32
|
-
end
|
33
|
-
creds['region'] = opts[:region]
|
34
|
-
@cloudwatch = Fog::AWS::CloudWatch.new(creds)
|
35
|
-
end
|
36
|
-
|
37
|
-
def tick
|
38
|
-
time = Time.new
|
39
|
-
%w[DatabaseConnections FreeableMemory FreeStorageSpace NetworkReceiveThroughput
|
40
|
-
NetworkTransmitThroughput ReadThroughput CPUUtilization].each do |metric|
|
41
|
-
result = @cloudwatch.get_metric_statistics(
|
42
|
-
'Namespace' => 'AWS/RDS',
|
43
|
-
'MetricName' => metric.to_s,
|
44
|
-
'Statistics' => 'Average',
|
45
|
-
'Dimensions' => [{ 'Name' => 'DBInstanceIdentifier', 'Value' => opts[:dbinstance_identifier].to_s }],
|
46
|
-
'StartTime' => (time - 120).to_time.iso8601,
|
47
|
-
'EndTime' => time.to_time.iso8601, 'Period' => 60,
|
48
|
-
)
|
49
|
-
metrics_result = result.data[:body]['GetMetricStatisticsResult']
|
50
|
-
next unless metrics_result['Datapoints'].length.positive?
|
51
|
-
|
52
|
-
datapoint = metrics_result['Datapoints'][0]
|
53
|
-
ev = {
|
54
|
-
metric: datapoint['Average'],
|
55
|
-
service: "#{opts[:dbinstance_identifier]}.#{metric} (#{datapoint['Unit']})",
|
56
|
-
description: JSON.dump(metrics_result),
|
57
|
-
state: 'ok',
|
58
|
-
ttl: 300,
|
59
|
-
}
|
60
|
-
|
61
|
-
report ev
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Riemann::Tools::AWS.run
|
8
|
+
Riemann::Tools::Aws::RdsStatus.run
|