maxwell_agent 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +63 -66
- data/README.md +22 -1
- data/bin/agent.rb +6 -0
- data/lib/maxwell/agent.rb +8 -5
- data/lib/maxwell/agent/attributes.rb +5 -0
- data/lib/maxwell/agent/coercable.rb +38 -0
- data/lib/maxwell/agent/evented_worker.rb +7 -0
- data/lib/maxwell/agent/host.rb +31 -10
- data/lib/maxwell/agent/host/service.rb +49 -0
- data/lib/maxwell/agent/middleware_runner.rb +11 -0
- data/lib/maxwell/agent/probe.rb +12 -0
- data/lib/maxwell/agent/redis_objects.rb +18 -0
- data/lib/maxwell/agent/redis_objects/set.rb +42 -0
- data/lib/maxwell/agent/redis_objects/sorted_set.rb +35 -0
- data/lib/maxwell/agent/runner.rb +18 -15
- data/lib/maxwell/agent/scheduler.rb +18 -14
- data/lib/maxwell/agent/standard_worker.rb +7 -0
- data/lib/maxwell/agent/version.rb +1 -1
- data/lib/maxwell/agent/work.rb +19 -44
- data/lib/maxwell/agent/work_schedule.rb +19 -52
- data/lib/maxwell/agent/worker.rb +1 -2
- data/maxwell_agent.gemspec +1 -0
- data/plugins/README.md +2 -0
- data/plugins/check_shell.rb +15 -0
- data/spec/agent/probe_spec.rb +13 -0
- data/spec/agent/scheduler_spec.rb +1 -6
- data/spec/agent/work_schedule_spec.rb +9 -9
- data/spec/agent/work_spec.rb +1 -12
- data/spec/spec_helper.rb +1 -1
- metadata +87 -59
- data/lib/maxwell/agent/dynamic_attributes.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aa26d6796cb79130f46288144c20ea309b0346a
|
4
|
+
data.tar.gz: 2c6a9ea962624a3eb023305e50c49b8cd69f116a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ee98b5428d23c31110aa1a5dc991dfc8f7295b140a1242341d4814cf14483c7c6517ff8947bd193e6a4822992c9935d8bac4e284d1b61d892935398f6b811f
|
7
|
+
data.tar.gz: 04a5d646281497f337b9b7e726bd967f221227886313829c11eab7ce280b5c7f286e434e7527575e4db407cfd87134f68ef7b9a45eb1b1f4d8397ff5dc9f4bd2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -8,12 +8,14 @@ group :development do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
gem 'rspec', group: [:test, :development]
|
11
|
-
gem 'rspec-given', group: [:test, :development]
|
11
|
+
gem 'rspec-given', "3.4.0", group: [:test, :development]
|
12
12
|
|
13
13
|
gem 'celluloid'
|
14
|
-
gem '
|
15
|
-
gem '
|
14
|
+
gem 'celluloid-io'
|
15
|
+
gem 'celluloid-redis'
|
16
|
+
gem 'redis', '~> 3.0.6'
|
16
17
|
gem 'connection_pool'
|
17
18
|
gem 'activesupport', require: ['active_support/core_ext/integer/time']
|
19
|
+
gem 'hashie'
|
18
20
|
|
19
21
|
gem 'rake', group: :test
|
data/Gemfile.lock
CHANGED
@@ -1,78 +1,83 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.0.
|
4
|
+
activesupport (4.0.3)
|
5
5
|
i18n (~> 0.6, >= 0.6.4)
|
6
6
|
minitest (~> 4.2)
|
7
7
|
multi_json (~> 1.3)
|
8
8
|
thread_safe (~> 0.1)
|
9
9
|
tzinfo (~> 0.3.37)
|
10
|
-
atomic (1.1.
|
11
|
-
atomic (1.1.
|
10
|
+
atomic (1.1.15)
|
11
|
+
atomic (1.1.15-java)
|
12
12
|
celluloid (0.15.2)
|
13
13
|
timers (~> 1.1.0)
|
14
14
|
celluloid-io (0.15.0)
|
15
15
|
celluloid (>= 0.15.0)
|
16
16
|
nio4r (>= 0.5.0)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
celluloid-redis (0.0.2)
|
18
|
+
celluloid-io (>= 0.13.0.pre)
|
19
|
+
redis
|
20
|
+
coderay (1.1.0)
|
21
|
+
connection_pool (1.2.0)
|
22
|
+
diff-lcs (1.2.5)
|
22
23
|
ffi (1.9.3)
|
23
24
|
ffi (1.9.3-java)
|
24
25
|
ffi2-generators (0.1.1)
|
25
26
|
formatador (0.2.4)
|
26
|
-
given_core (3.
|
27
|
+
given_core (3.4.0)
|
27
28
|
sorcerer (>= 0.3.7)
|
28
|
-
guard (2.
|
29
|
+
guard (2.5.1)
|
29
30
|
formatador (>= 0.2.4)
|
30
|
-
listen (~> 2.
|
31
|
+
listen (~> 2.6)
|
31
32
|
lumberjack (~> 1.0)
|
32
33
|
pry (>= 0.9.12)
|
33
34
|
thor (>= 0.18.1)
|
34
|
-
guard-rspec (4.
|
35
|
-
guard (
|
36
|
-
rspec (
|
37
|
-
|
35
|
+
guard-rspec (4.2.7)
|
36
|
+
guard (~> 2.1)
|
37
|
+
rspec (>= 2.14, < 4.0)
|
38
|
+
hashie (2.0.5)
|
39
|
+
i18n (0.6.9)
|
38
40
|
json (1.8.1)
|
39
41
|
json (1.8.1-java)
|
40
|
-
listen (2.2
|
42
|
+
listen (2.6.2)
|
41
43
|
celluloid (>= 0.15.2)
|
44
|
+
celluloid-io (>= 0.15.0)
|
42
45
|
rb-fsevent (>= 0.9.3)
|
43
46
|
rb-inotify (>= 0.9)
|
44
47
|
lumberjack (1.0.4)
|
45
48
|
method_source (0.8.2)
|
46
49
|
minitest (4.7.5)
|
47
|
-
multi_json (1.8.
|
48
|
-
|
49
|
-
|
50
|
+
multi_json (1.8.4)
|
51
|
+
nio4r (1.0.0)
|
52
|
+
nio4r (1.0.0-java)
|
53
|
+
pry (0.9.12.6)
|
54
|
+
coderay (~> 1.0)
|
50
55
|
method_source (~> 0.8)
|
51
56
|
slop (~> 3.4)
|
52
|
-
pry (0.9.12.
|
53
|
-
coderay (~> 1.0
|
57
|
+
pry (0.9.12.6-java)
|
58
|
+
coderay (~> 1.0)
|
54
59
|
method_source (~> 0.8)
|
55
60
|
slop (~> 3.4)
|
56
61
|
spoon (~> 0.0)
|
57
|
-
rake (10.1.
|
58
|
-
rb-fsevent (0.9.
|
59
|
-
rb-inotify (0.9.
|
62
|
+
rake (10.1.1)
|
63
|
+
rb-fsevent (0.9.4)
|
64
|
+
rb-inotify (0.9.3)
|
60
65
|
ffi (>= 0.5.0)
|
61
66
|
rdoc (3.12.2)
|
62
67
|
json (~> 1.4)
|
63
|
-
redis (3.0.
|
68
|
+
redis (3.0.7)
|
64
69
|
rspec (2.14.1)
|
65
70
|
rspec-core (~> 2.14.0)
|
66
71
|
rspec-expectations (~> 2.14.0)
|
67
72
|
rspec-mocks (~> 2.14.0)
|
68
|
-
rspec-core (2.14.
|
69
|
-
rspec-expectations (2.14.
|
73
|
+
rspec-core (2.14.8)
|
74
|
+
rspec-expectations (2.14.5)
|
70
75
|
diff-lcs (>= 1.1.3, < 2.0)
|
71
|
-
rspec-given (3.
|
72
|
-
given_core (= 3.
|
76
|
+
rspec-given (3.4.0)
|
77
|
+
given_core (= 3.4.0)
|
73
78
|
rspec (>= 2.12)
|
74
|
-
rspec-mocks (2.14.
|
75
|
-
rubysl (2.0.
|
79
|
+
rspec-mocks (2.14.6)
|
80
|
+
rubysl (2.0.15)
|
76
81
|
rubysl-abbrev (~> 2.0)
|
77
82
|
rubysl-base64 (~> 2.0)
|
78
83
|
rubysl-benchmark (~> 2.0)
|
@@ -107,7 +112,6 @@ GEM
|
|
107
112
|
rubysl-io-wait (~> 2.0)
|
108
113
|
rubysl-ipaddr (~> 2.0)
|
109
114
|
rubysl-irb (~> 2.0)
|
110
|
-
rubysl-json (~> 2.0)
|
111
115
|
rubysl-logger (~> 2.0)
|
112
116
|
rubysl-mathn (~> 2.0)
|
113
117
|
rubysl-matrix (~> 2.0)
|
@@ -140,7 +144,6 @@ GEM
|
|
140
144
|
rubysl-resolv (~> 2.0)
|
141
145
|
rubysl-rexml (~> 2.0)
|
142
146
|
rubysl-rinda (~> 2.0)
|
143
|
-
rubysl-ripper (~> 2.0)
|
144
147
|
rubysl-rss (~> 2.0)
|
145
148
|
rubysl-scanf (~> 2.0)
|
146
149
|
rubysl-securerandom (~> 2.0)
|
@@ -153,13 +156,11 @@ GEM
|
|
153
156
|
rubysl-sync (~> 2.0)
|
154
157
|
rubysl-syslog (~> 2.0)
|
155
158
|
rubysl-tempfile (~> 2.0)
|
156
|
-
rubysl-test-unit (~> 2.0)
|
157
159
|
rubysl-thread (~> 2.0)
|
158
160
|
rubysl-thwait (~> 2.0)
|
159
161
|
rubysl-time (~> 2.0)
|
160
162
|
rubysl-timeout (~> 2.0)
|
161
163
|
rubysl-tmpdir (~> 2.0)
|
162
|
-
rubysl-tracer (~> 2.0)
|
163
164
|
rubysl-tsort (~> 2.0)
|
164
165
|
rubysl-un (~> 2.0)
|
165
166
|
rubysl-uri (~> 2.0)
|
@@ -168,36 +169,36 @@ GEM
|
|
168
169
|
rubysl-xmlrpc (~> 2.0)
|
169
170
|
rubysl-yaml (~> 2.0)
|
170
171
|
rubysl-zlib (~> 2.0)
|
171
|
-
rubysl-abbrev (2.0.
|
172
|
+
rubysl-abbrev (2.0.4)
|
172
173
|
rubysl-base64 (2.0.0)
|
173
|
-
rubysl-benchmark (2.0.
|
174
|
+
rubysl-benchmark (2.0.1)
|
174
175
|
rubysl-bigdecimal (2.0.2)
|
175
|
-
rubysl-cgi (2.0.
|
176
|
-
rubysl-cgi-session (2.0.
|
176
|
+
rubysl-cgi (2.0.1)
|
177
|
+
rubysl-cgi-session (2.0.1)
|
177
178
|
rubysl-cmath (2.0.0)
|
178
179
|
rubysl-complex (2.0.0)
|
179
180
|
rubysl-continuation (2.0.0)
|
180
181
|
rubysl-coverage (2.0.3)
|
181
|
-
rubysl-csv (2.0.
|
182
|
+
rubysl-csv (2.0.2)
|
182
183
|
rubysl-english (~> 2.0)
|
183
|
-
rubysl-curses (2.0.
|
184
|
+
rubysl-curses (2.0.1)
|
184
185
|
rubysl-date (2.0.6)
|
185
|
-
rubysl-delegate (2.0.
|
186
|
+
rubysl-delegate (2.0.1)
|
186
187
|
rubysl-digest (2.0.3)
|
187
188
|
rubysl-drb (2.0.1)
|
188
189
|
rubysl-e2mmap (2.0.0)
|
189
190
|
rubysl-english (2.0.0)
|
190
191
|
rubysl-enumerator (2.0.0)
|
191
|
-
rubysl-erb (2.0.
|
192
|
+
rubysl-erb (2.0.1)
|
192
193
|
rubysl-etc (2.0.3)
|
193
194
|
ffi2-generators (~> 0.1)
|
194
195
|
rubysl-expect (2.0.0)
|
195
196
|
rubysl-fcntl (2.0.4)
|
196
197
|
ffi2-generators (~> 0.1)
|
197
198
|
rubysl-fiber (2.0.0)
|
198
|
-
rubysl-fileutils (2.0.
|
199
|
-
rubysl-find (2.0.
|
200
|
-
rubysl-forwardable (2.0.
|
199
|
+
rubysl-fileutils (2.0.3)
|
200
|
+
rubysl-find (2.0.1)
|
201
|
+
rubysl-forwardable (2.0.1)
|
201
202
|
rubysl-getoptlong (2.0.0)
|
202
203
|
rubysl-gserver (2.0.0)
|
203
204
|
rubysl-socket (~> 2.0)
|
@@ -206,13 +207,11 @@ GEM
|
|
206
207
|
rubysl-io-nonblock (2.0.0)
|
207
208
|
rubysl-io-wait (2.0.0)
|
208
209
|
rubysl-ipaddr (2.0.0)
|
209
|
-
rubysl-irb (2.0.
|
210
|
+
rubysl-irb (2.0.4)
|
210
211
|
rubysl-e2mmap (~> 2.0)
|
211
212
|
rubysl-mathn (~> 2.0)
|
212
213
|
rubysl-readline (~> 2.0)
|
213
214
|
rubysl-thread (~> 2.0)
|
214
|
-
rubysl-tracer (~> 2.0)
|
215
|
-
rubysl-json (2.0.2)
|
216
215
|
rubysl-logger (2.0.0)
|
217
216
|
rubysl-mathn (2.0.0)
|
218
217
|
rubysl-matrix (2.1.0)
|
@@ -236,23 +235,22 @@ GEM
|
|
236
235
|
rubysl-observer (2.0.0)
|
237
236
|
rubysl-open-uri (2.0.0)
|
238
237
|
rubysl-open3 (2.0.0)
|
239
|
-
rubysl-openssl (2.0
|
238
|
+
rubysl-openssl (2.1.0)
|
240
239
|
rubysl-optparse (2.0.1)
|
241
240
|
rubysl-shellwords (~> 2.0)
|
242
241
|
rubysl-ostruct (2.0.4)
|
243
242
|
rubysl-pathname (2.0.0)
|
244
243
|
rubysl-prettyprint (2.0.2)
|
245
|
-
rubysl-prime (2.0.
|
244
|
+
rubysl-prime (2.0.1)
|
246
245
|
rubysl-profile (2.0.0)
|
247
246
|
rubysl-profiler (2.0.1)
|
248
247
|
rubysl-pstore (2.0.0)
|
249
248
|
rubysl-pty (2.0.2)
|
250
249
|
rubysl-rational (2.0.1)
|
251
250
|
rubysl-readline (2.0.2)
|
252
|
-
rubysl-resolv (2.
|
251
|
+
rubysl-resolv (2.1.0)
|
253
252
|
rubysl-rexml (2.0.2)
|
254
|
-
rubysl-rinda (2.0.
|
255
|
-
rubysl-ripper (2.0.0)
|
253
|
+
rubysl-rinda (2.0.1)
|
256
254
|
rubysl-rss (2.0.0)
|
257
255
|
rubysl-scanf (2.0.0)
|
258
256
|
rubysl-securerandom (2.0.0)
|
@@ -266,14 +264,11 @@ GEM
|
|
266
264
|
rubysl-syslog (2.0.1)
|
267
265
|
ffi2-generators (~> 0.1)
|
268
266
|
rubysl-tempfile (2.0.1)
|
269
|
-
rubysl-test-unit (2.0.1)
|
270
|
-
minitest (~> 4.7)
|
271
267
|
rubysl-thread (2.0.2)
|
272
268
|
rubysl-thwait (2.0.0)
|
273
269
|
rubysl-time (2.0.3)
|
274
270
|
rubysl-timeout (2.0.0)
|
275
271
|
rubysl-tmpdir (2.0.0)
|
276
|
-
rubysl-tracer (2.0.0)
|
277
272
|
rubysl-tsort (2.0.1)
|
278
273
|
rubysl-un (2.0.0)
|
279
274
|
rubysl-fileutils (~> 2.0)
|
@@ -282,17 +277,17 @@ GEM
|
|
282
277
|
rubysl-weakref (2.0.0)
|
283
278
|
rubysl-webrick (2.0.0)
|
284
279
|
rubysl-xmlrpc (2.0.0)
|
285
|
-
rubysl-yaml (2.0.
|
280
|
+
rubysl-yaml (2.0.4)
|
286
281
|
rubysl-zlib (2.0.1)
|
287
|
-
slop (3.4.
|
282
|
+
slop (3.4.7)
|
288
283
|
sorcerer (1.0.2)
|
289
284
|
spoon (0.0.4)
|
290
285
|
ffi
|
291
286
|
thor (0.18.1)
|
292
|
-
thread_safe (0.
|
293
|
-
atomic
|
294
|
-
thread_safe (0.
|
295
|
-
atomic
|
287
|
+
thread_safe (0.2.0)
|
288
|
+
atomic (>= 1.1.7, < 2)
|
289
|
+
thread_safe (0.2.0-java)
|
290
|
+
atomic (>= 1.1.7, < 2)
|
296
291
|
timers (1.1.0)
|
297
292
|
tzinfo (0.3.38)
|
298
293
|
|
@@ -304,13 +299,15 @@ DEPENDENCIES
|
|
304
299
|
activesupport
|
305
300
|
bundler (~> 1.0)
|
306
301
|
celluloid
|
302
|
+
celluloid-io
|
303
|
+
celluloid-redis
|
307
304
|
connection_pool
|
308
|
-
fakeredis
|
309
305
|
guard
|
310
306
|
guard-rspec
|
307
|
+
hashie
|
311
308
|
rake
|
312
309
|
rdoc (~> 3.12)
|
313
|
-
redis
|
310
|
+
redis (~> 3.0.6)
|
314
311
|
rspec
|
315
|
-
rspec-given
|
312
|
+
rspec-given (= 3.4.0)
|
316
313
|
rubysl (~> 2.0)
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ This is still in early development, use at your own risk
|
|
23
23
|
|
24
24
|
To use:
|
25
25
|
```ruby
|
26
|
-
require '
|
26
|
+
require 'maxwell_agent'
|
27
27
|
Maxwell::Agent.start!
|
28
28
|
```
|
29
29
|
Check out config/schedule.rb for an example on how to schedule work.<br />
|
@@ -67,6 +67,27 @@ Everything before the yield is called before passing on to the next middleware<b
|
|
67
67
|
Everything after the yield is called after the rest of the middleware stack has run<br>
|
68
68
|
If you do not yield in your middleware call it will break the chain (and likely the app)
|
69
69
|
|
70
|
+
|
71
|
+
### Probes
|
72
|
+
Probes are the actual monitoring checks that get performed.<br />
|
73
|
+
To create a probe include "Maxwell::Agent::Probe" into your class.<br />
|
74
|
+
You must define a "perform" instnace method which is what gets called by Maxwell Agent.<br />
|
75
|
+
You can optionally define a "handle" instance method which gets run after perform, and should take a single argument<br />
|
76
|
+
|
77
|
+
By default when your probe is scheduled it is sent to a worker pool to complete.
|
78
|
+
Maxwell also has the ability to take advantage of evented I/O.<br />
|
79
|
+
If you know your probe uses evented/non-blocking IO compatible with Celluloid add the following to your class:
|
80
|
+
```ruby
|
81
|
+
class Foo
|
82
|
+
include Maxwell::Agent::Probe
|
83
|
+
|
84
|
+
self.work_type = :evented
|
85
|
+
end
|
86
|
+
```
|
87
|
+
The work type option will have your probe sent to the evented worker instead of the normal worker pool.<br />
|
88
|
+
Only set this option if your probe is doing mostly non-blocking I/O.<br />
|
89
|
+
Maxwell will come with several pre-built evented I/O probes that you can use.
|
90
|
+
|
70
91
|
## Contributing to agent
|
71
92
|
|
72
93
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/bin/agent.rb
ADDED
data/lib/maxwell/agent.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'active_support/core_ext/integer/time'
|
3
3
|
require 'celluloid'
|
4
|
+
require 'celluloid/io'
|
5
|
+
require 'celluloid/redis'
|
4
6
|
require 'redis'
|
5
7
|
require 'connection_pool'
|
6
8
|
require 'json'
|
7
|
-
|
9
|
+
require 'hashie'
|
10
|
+
require 'maxwell/agent/attributes'
|
11
|
+
require 'maxwell/agent/coercable'
|
12
|
+
require 'maxwell/agent/redis_objects'
|
8
13
|
require 'maxwell/agent/configuration'
|
9
|
-
require 'maxwell/agent/dynamic_attributes'
|
10
14
|
require 'maxwell/agent/middleware/chain'
|
11
15
|
require 'maxwell/agent/middleware/logging'
|
12
16
|
require 'maxwell/agent/work'
|
@@ -62,7 +66,7 @@ module Maxwell
|
|
62
66
|
def redis(&block)
|
63
67
|
@redis ||= ConnectionPool.new(
|
64
68
|
size: (configuration.worker_concurrency + 2)) {
|
65
|
-
Redis.new configuration.redis_options
|
69
|
+
Redis.new({driver: :celluloid}.merge(configuration.redis_options))
|
66
70
|
}
|
67
71
|
@redis.with(&block)
|
68
72
|
end
|
@@ -85,8 +89,7 @@ module Maxwell
|
|
85
89
|
end
|
86
90
|
end
|
87
91
|
end
|
88
|
-
|
89
|
-
Dir[File.dirname(__FILE__) + '/../plugins/*.rb'].each do |file|
|
92
|
+
Dir[File.dirname(__FILE__) + '/../../plugins/*.rb'].each do |file|
|
90
93
|
require file
|
91
94
|
end
|
92
95
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Maxwell
|
2
|
+
module Agent
|
3
|
+
module Coercable
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
base.instance_variable_set('@coercions', {})
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def coerce_values!(attrs)
|
11
|
+
attrs.each do |key, value|
|
12
|
+
attrs[key] = coerce_value(key, value) if self.class.coercions[key]
|
13
|
+
end
|
14
|
+
attrs
|
15
|
+
end
|
16
|
+
|
17
|
+
def coerce_value(key, value)
|
18
|
+
coercion_class = self.class.coercions[key]
|
19
|
+
case
|
20
|
+
when coercion_class.is_a?(Proc) then coercion_class.call(value)
|
21
|
+
else coercion_class.new(value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def coercions
|
27
|
+
@coercions ||= {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def coerce(key, as)
|
31
|
+
@coercions[key] = as
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|