arborist 0.0.1.pre20160606141735 → 0.0.1.pre20160829140603
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +81 -2
- data/Events.md +11 -11
- data/Manifest.txt +2 -4
- data/TODO.md +9 -29
- data/lib/arborist.rb +6 -2
- data/lib/arborist/command/watch.rb +59 -8
- data/lib/arborist/loader/file.rb +1 -1
- data/lib/arborist/manager.rb +139 -50
- data/lib/arborist/manager/event_publisher.rb +29 -0
- data/lib/arborist/manager/tree_api.rb +16 -1
- data/lib/arborist/mixins.rb +36 -1
- data/lib/arborist/monitor.rb +12 -0
- data/lib/arborist/monitor/socket.rb +8 -9
- data/lib/arborist/monitor_runner.rb +2 -2
- data/lib/arborist/node.rb +16 -3
- data/lib/arborist/node/host.rb +25 -22
- data/lib/arborist/node/resource.rb +28 -14
- data/lib/arborist/node/service.rb +21 -2
- data/lib/arborist/observer_runner.rb +68 -7
- data/spec/arborist/client_spec.rb +3 -3
- data/spec/arborist/manager/event_publisher_spec.rb +0 -1
- data/spec/arborist/manager/tree_api_spec.rb +6 -5
- data/spec/arborist/manager_spec.rb +53 -24
- data/spec/arborist/node/resource_spec.rb +9 -0
- data/spec/arborist/node/service_spec.rb +16 -1
- data/spec/arborist/node_spec.rb +22 -12
- data/spec/arborist/observer_runner_spec.rb +58 -0
- data/spec/arborist/observer_spec.rb +15 -15
- data/spec/arborist/subscription_spec.rb +1 -1
- data/spec/data/nodes/{duir.rb → sub/duir.rb} +0 -0
- data/spec/data/observers/auditor.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- metadata +30 -27
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -2
- data/lib/arborist/event/sys_node_added.rb +0 -10
- data/lib/arborist/event/sys_node_removed.rb +0 -10
- data/lib/arborist/event/sys_reloaded.rb +0 -15
- metadata.gz.sig +0 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env rspec -cfd
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
require 'arborist/observer_runner'
|
6
|
+
|
7
|
+
|
8
|
+
describe Arborist::ObserverRunner do
|
9
|
+
|
10
|
+
|
11
|
+
let( :zmq_loop ) { instance_double(ZMQ::Loop) }
|
12
|
+
let( :req_socket ) { instance_double(ZMQ::Socket::Req) }
|
13
|
+
let( :sub_socket ) { instance_double(ZMQ::Socket::Sub) }
|
14
|
+
let( :pollitem ) { instance_double(ZMQ::Pollitem) }
|
15
|
+
|
16
|
+
let( :runner ) do
|
17
|
+
obj = described_class.new
|
18
|
+
obj.reactor = zmq_loop
|
19
|
+
obj
|
20
|
+
end
|
21
|
+
|
22
|
+
let( :observer_class ) { Class.new(Arborist::Observer) }
|
23
|
+
|
24
|
+
let( :observer1 ) { observer_class.new("testing observer1") }
|
25
|
+
let( :observer2 ) { observer_class.new("testing observer2") }
|
26
|
+
let( :observer3 ) { observer_class.new("testing observer3") }
|
27
|
+
let( :observers ) {[ observer1, observer2, observer3 ]}
|
28
|
+
|
29
|
+
|
30
|
+
it "can load observers from an enumerator that yields Arborist::Observers" do
|
31
|
+
runner.load_observers([ observer1, observer2, observer3 ])
|
32
|
+
expect( runner.observers ).to include( observer1, observer2, observer3 )
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
describe "a runner with loaded observers" do
|
37
|
+
|
38
|
+
before( :each ) do
|
39
|
+
allow( zmq_loop ).to receive( :register ).with( an_instance_of(ZMQ::Pollitem) )
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
xit "subscribes to events for each of its observers and starts the ZMQ loop when run" do
|
44
|
+
expect( Arborist.zmq_context ).to receive( :socket ).
|
45
|
+
with( :REQ ).and_return( req_socket )
|
46
|
+
expect( Arborist.zmq_context ).to receive( :socket ).
|
47
|
+
with( :SUB ).and_return( sub_socket )
|
48
|
+
|
49
|
+
expect( req_socket ).to receive( :subscribe ).with( )
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
describe Arborist::ObserverRunner::Handler
|
56
|
+
|
57
|
+
end
|
58
|
+
|
@@ -45,8 +45,8 @@ describe Arborist::Observer do
|
|
45
45
|
|
46
46
|
it "can specify an action to run when a subscribed event is received" do
|
47
47
|
observer = described_class.new( "testing observer" ) do
|
48
|
-
action do |
|
49
|
-
|
48
|
+
action do |event|
|
49
|
+
# no-op
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -57,11 +57,11 @@ describe Arborist::Observer do
|
|
57
57
|
|
58
58
|
it "can specify more than one action to run when a subscribed event is received" do
|
59
59
|
observer = described_class.new( "testing observer" ) do
|
60
|
-
action do |
|
61
|
-
|
60
|
+
action do |event|
|
61
|
+
# no-op
|
62
62
|
end
|
63
|
-
action do |
|
64
|
-
|
63
|
+
action do |event|
|
64
|
+
# no-op
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -74,7 +74,7 @@ describe Arborist::Observer do
|
|
74
74
|
it "can specify a summary action" do
|
75
75
|
observer = described_class.new( "testing observer" ) do
|
76
76
|
summarize( every: 5 ) do |events|
|
77
|
-
|
77
|
+
# no-op
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -87,10 +87,10 @@ describe Arborist::Observer do
|
|
87
87
|
it "can specify a mix of regular and summary actions" do
|
88
88
|
observer = described_class.new( "testing observer" ) do
|
89
89
|
summarize( every: 5 ) do |events|
|
90
|
-
|
90
|
+
# no-op
|
91
91
|
end
|
92
|
-
action do |
|
93
|
-
|
92
|
+
action do |event|
|
93
|
+
# no-op
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -104,10 +104,10 @@ describe Arborist::Observer do
|
|
104
104
|
it "passes events it is given to handle to its actions" do
|
105
105
|
observer = described_class.new( "testing observer" ) do
|
106
106
|
summarize( every: 5 ) do |events|
|
107
|
-
|
107
|
+
# no-op
|
108
108
|
end
|
109
|
-
action do |
|
110
|
-
|
109
|
+
action do |event|
|
110
|
+
# no-op
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -126,8 +126,8 @@ describe Arborist::Observer do
|
|
126
126
|
summarize( every: 5 ) do |events|
|
127
127
|
summarize_called = true
|
128
128
|
end
|
129
|
-
action do |
|
130
|
-
|
129
|
+
action do |event|
|
130
|
+
# no-op
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
@@ -48,7 +48,7 @@ describe Arborist::Subscription do
|
|
48
48
|
it "publishes events which are of any type if the specified type is `nil`" do
|
49
49
|
subscription = described_class.new( &published_events.method(:push) )
|
50
50
|
event1 = Arborist::Event.create( 'node_delta', host_node, status: ['up', 'down'] )
|
51
|
-
event2 = Arborist::Event.create( '
|
51
|
+
event2 = Arborist::Event.create( 'node_update', host_node )
|
52
52
|
|
53
53
|
subscription.on_events( event1, event2 )
|
54
54
|
|
File without changes
|
@@ -6,8 +6,8 @@ require 'arborist'
|
|
6
6
|
|
7
7
|
Arborist::Observer "Audit Logger" do
|
8
8
|
subscribe to: 'node.update', on: 'localhost'
|
9
|
-
action do |
|
10
|
-
$stderr.puts "%
|
9
|
+
action do |event|
|
10
|
+
$stderr.puts "%p" % [ event ]
|
11
11
|
end
|
12
12
|
summarize( every: 8 ) do |events|
|
13
13
|
$stderr.puts "Audit summary:"
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arborist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.pre20160829140603
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -11,26 +11,32 @@ bindir: bin
|
|
11
11
|
cert_chain:
|
12
12
|
- |
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
14
|
+
MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
|
15
15
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEz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YWVyaWVNVUQub3JnMBwGA1UdEgQVMBOBEWdlZEBG
|
29
|
+
YWVyaWVNVUQub3JnMA0GCSqGSIb3DQEBCwUAA4IBgQAPJzKiT0zBU7kpqe0aS2qb
|
30
|
+
FI0PJ4y5I8buU4IZGUD5NEt/N7pZNfOyBxkrZkXhS44Fp+xwBH5ebLbq/WY78Bqd
|
31
|
+
db0z6ZgW4LMYMpWFfbXsRbd9TU2f52L8oMAhxOvF7Of5qJMVWuFQ8FPagk2iHrdH
|
32
|
+
inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
|
33
|
+
DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
|
34
|
+
PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
|
35
|
+
6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
|
36
|
+
w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
|
37
|
+
p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
|
32
38
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-
|
39
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
34
40
|
dependencies:
|
35
41
|
- !ruby/object:Gem::Dependency
|
36
42
|
name: schedulability
|
@@ -178,14 +184,14 @@ dependencies:
|
|
178
184
|
requirements:
|
179
185
|
- - "~>"
|
180
186
|
- !ruby/object:Gem::Version
|
181
|
-
version: '0.
|
187
|
+
version: '0.8'
|
182
188
|
type: :development
|
183
189
|
prerelease: false
|
184
190
|
version_requirements: !ruby/object:Gem::Requirement
|
185
191
|
requirements:
|
186
192
|
- - "~>"
|
187
193
|
- !ruby/object:Gem::Version
|
188
|
-
version: '0.
|
194
|
+
version: '0.8'
|
189
195
|
- !ruby/object:Gem::Dependency
|
190
196
|
name: hoe-highline
|
191
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,14 +268,14 @@ dependencies:
|
|
262
268
|
requirements:
|
263
269
|
- - "~>"
|
264
270
|
- !ruby/object:Gem::Version
|
265
|
-
version: '3.
|
271
|
+
version: '3.15'
|
266
272
|
type: :development
|
267
273
|
prerelease: false
|
268
274
|
version_requirements: !ruby/object:Gem::Requirement
|
269
275
|
requirements:
|
270
276
|
- - "~>"
|
271
277
|
- !ruby/object:Gem::Version
|
272
|
-
version: '3.
|
278
|
+
version: '3.15'
|
273
279
|
description: |-
|
274
280
|
Arborist is a monitoring toolkit that follows the UNIX philosophy
|
275
281
|
of small parts and loose coupling for stability, reliability, and
|
@@ -327,9 +333,6 @@ files:
|
|
327
333
|
- lib/arborist/event/node_unknown.rb
|
328
334
|
- lib/arborist/event/node_up.rb
|
329
335
|
- lib/arborist/event/node_update.rb
|
330
|
-
- lib/arborist/event/sys_node_added.rb
|
331
|
-
- lib/arborist/event/sys_node_removed.rb
|
332
|
-
- lib/arborist/event/sys_reloaded.rb
|
333
336
|
- lib/arborist/exceptions.rb
|
334
337
|
- lib/arborist/loader.rb
|
335
338
|
- lib/arborist/loader/file.rb
|
@@ -373,6 +376,7 @@ files:
|
|
373
376
|
- spec/arborist/node_spec.rb
|
374
377
|
- spec/arborist/observer/action_spec.rb
|
375
378
|
- spec/arborist/observer/summarize_spec.rb
|
379
|
+
- spec/arborist/observer_runner_spec.rb
|
376
380
|
- spec/arborist/observer_spec.rb
|
377
381
|
- spec/arborist/subscription_spec.rb
|
378
382
|
- spec/arborist_spec.rb
|
@@ -380,9 +384,9 @@ files:
|
|
380
384
|
- spec/data/monitors/port_checks.rb
|
381
385
|
- spec/data/monitors/system_resources.rb
|
382
386
|
- spec/data/monitors/web_services.rb
|
383
|
-
- spec/data/nodes/duir.rb
|
384
387
|
- spec/data/nodes/localhost.rb
|
385
388
|
- spec/data/nodes/sidonie.rb
|
389
|
+
- spec/data/nodes/sub/duir.rb
|
386
390
|
- spec/data/nodes/yevaud.rb
|
387
391
|
- spec/data/observers/auditor.rb
|
388
392
|
- spec/data/observers/webservices.rb
|
@@ -415,4 +419,3 @@ specification_version: 4
|
|
415
419
|
summary: Arborist is a monitoring toolkit that follows the UNIX philosophy of small
|
416
420
|
parts and loose coupling for stability, reliability, and customizability
|
417
421
|
test_files: []
|
418
|
-
has_rdoc:
|
checksums.yaml.gz.sig
DELETED
Binary file
|
data.tar.gz.sig
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
|
-
|
4
|
-
require 'arborist/event' unless defined?( Arborist::Event )
|
5
|
-
require 'arborist/event/node'
|
6
|
-
|
7
|
-
|
8
|
-
# A system event generated when a node is added to the tree.
|
9
|
-
class Arborist::Event::SysNodeAdded < Arborist::Event::Node
|
10
|
-
end # class Arborist::Event::SysNodeAdded
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
|
-
|
4
|
-
require 'arborist/event' unless defined?( Arborist::Event )
|
5
|
-
require 'arborist/event/node'
|
6
|
-
|
7
|
-
|
8
|
-
# A system event generated when a node is removed from the tree.
|
9
|
-
class Arborist::Event::SysNodeRemoved < Arborist::Event::Node
|
10
|
-
end # class Arborist::Event::SysNodeRemoved
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'arborist/node' unless defined?( Arborist::Node )
|
4
|
-
|
5
|
-
|
6
|
-
# An event sent when the manager reloads the node tree.
|
7
|
-
class Arborist::Event::SysReloaded < Arborist::Event
|
8
|
-
|
9
|
-
|
10
|
-
### Create a NodeUpdate event for the specified +node+.
|
11
|
-
def initialize( payload=Time.now )
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
end # class Arborist::Event::NodeUpdate
|
metadata.gz.sig
DELETED
Binary file
|