reacter 0.0.6 → 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/lib/reacter/adapter.rb +7 -5
- data/lib/reacter/adapters/amqp.rb +8 -1
- data/lib/reacter/core.rb +2 -16
- data/lib/reacter/parser.rb +23 -0
- data/lib/reacter/parsers/collectd.rb +2 -2
- data/lib/reacter/parsers/graphite.rb +2 -2
- data/lib/reacter/parsers/json.rb +2 -2
- data/lib/reacter/parsers/tsdb.rb +2 -2
- metadata +2 -2
- data/lib/reacter/parsers/default.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 698f0acf6a91c8a8f222c2b5a9c794a9649b1b9f
|
4
|
+
data.tar.gz: df4407d0644729a0f432e9dba966caa10fc30a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db488df26691082e2ef23d48675359075856e68a0936a803175ddf177508ea2f53fb4046eb49f35468733f45bb8ce412c7fdb864b0d116a8ea57152bd85deb8
|
7
|
+
data.tar.gz: f7478402230db72f05b0d8cfd91585a13aeb832d1c795e33669f0d4b7b40b23c842107cd8cd91ba02cd953f7e4385b2809fd246b10d931ed7f28bb9a51bb764d
|
data/lib/reacter/adapter.rb
CHANGED
@@ -6,12 +6,14 @@ require 'reacter/message'
|
|
6
6
|
require 'reacter/config'
|
7
7
|
require 'reacter/util'
|
8
8
|
|
9
|
-
class AdapterConnectionFailed < Exception; end
|
10
|
-
class AdapterConnectionFaulted < Exception; end
|
11
|
-
class AdapterConnectionClosed < Exception; end
|
12
|
-
class AdapterExit < Exception; end
|
13
9
|
|
14
10
|
class Reacter
|
11
|
+
class AdapterConnectionFailed < Exception; end
|
12
|
+
class AdapterConnectionFaulted < Exception; end
|
13
|
+
class AdapterConnectionClosed < Exception; end
|
14
|
+
class AdapterExit < Exception; end
|
15
|
+
|
16
|
+
|
15
17
|
class Adapter
|
16
18
|
attr :config
|
17
19
|
attr :type
|
@@ -42,7 +44,7 @@ class Reacter
|
|
42
44
|
|
43
45
|
# implement: manual disconnect / cleanup
|
44
46
|
def disconnect()
|
45
|
-
|
47
|
+
@_connected = false
|
46
48
|
end
|
47
49
|
|
48
50
|
def disable()
|
@@ -10,14 +10,21 @@ class Reacter
|
|
10
10
|
require 'amqp'
|
11
11
|
|
12
12
|
DEFAULT_QUEUENAME='reacter'
|
13
|
+
DEFAULT_TIMEOUT=3
|
13
14
|
|
14
15
|
def connect(args={})
|
16
|
+
@_errback = proc do
|
17
|
+
raise AdapterConnectionFailed
|
18
|
+
end
|
19
|
+
|
15
20
|
@_connection = AMQP.connect({
|
16
21
|
:host => @config.get(:hostname, 'localhost'),
|
17
22
|
:port => @config.get(:port, 5672),
|
18
23
|
:username => @config.get(:username, 'guest'),
|
19
24
|
:password => @config.get(:password, 'guest'),
|
20
|
-
:vhost => @config.get(:vhost, '/')
|
25
|
+
:vhost => @config.get(:vhost, '/'),
|
26
|
+
:timeout => @config.get(:timeout, DEFAULT_TIMEOUT),
|
27
|
+
:on_tcp_connection_failure => @_errback
|
21
28
|
})
|
22
29
|
|
23
30
|
@_channel = AMQP::Channel.new(@_connection)
|
data/lib/reacter/core.rb
CHANGED
@@ -36,7 +36,6 @@ class Reacter
|
|
36
36
|
@_adapters << instance
|
37
37
|
else
|
38
38
|
raise "Adapter '#{type}' not found, exiting"
|
39
|
-
exit 1
|
40
39
|
end
|
41
40
|
end
|
42
41
|
else
|
@@ -80,21 +79,8 @@ class Reacter
|
|
80
79
|
next unless adapter.enabled?
|
81
80
|
|
82
81
|
poller = proc do
|
83
|
-
|
84
|
-
|
85
|
-
dispatch.call(messages)
|
86
|
-
end
|
87
|
-
rescue AdapterConnectionFailed => e
|
88
|
-
Util.error("Adapter connection failed: #{e.message}")
|
89
|
-
|
90
|
-
rescue AdapterConnectionFaulted => e
|
91
|
-
Util.error("Adapter connection error: #{e.message}")
|
92
|
-
|
93
|
-
rescue AdapterConnectionClosed => e
|
94
|
-
Util.info("Adapter closed connection")
|
95
|
-
|
96
|
-
rescue AdapterExit => e
|
97
|
-
adapter.disable()
|
82
|
+
adapter.poll do |messages|
|
83
|
+
dispatch.call(messages)
|
98
84
|
end
|
99
85
|
end
|
100
86
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Reacter
|
2
|
+
class Message
|
3
|
+
class Parser
|
4
|
+
class<<self
|
5
|
+
# implement: determine whether the raw message is in a format this parser
|
6
|
+
# can normalize
|
7
|
+
def detected?(message)
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
# implement: parse the raw input message, returning an array of Messages
|
12
|
+
def parse(message)
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
# take a Message and return the orginal format
|
17
|
+
def dump(message)
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/reacter/parsers/json.rb
CHANGED
data/lib/reacter/parsers/tsdb.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reacter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Hetzel
|
@@ -71,8 +71,8 @@ files:
|
|
71
71
|
- lib/reacter/config.rb
|
72
72
|
- lib/reacter/core.rb
|
73
73
|
- lib/reacter/message.rb
|
74
|
+
- lib/reacter/parser.rb
|
74
75
|
- lib/reacter/parsers/collectd.rb
|
75
|
-
- lib/reacter/parsers/default.rb
|
76
76
|
- lib/reacter/parsers/graphite.rb
|
77
77
|
- lib/reacter/parsers/json.rb
|
78
78
|
- lib/reacter/parsers/tsdb.rb
|