scout_agent 3.2.5 → 3.2.6
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.
- data/CHANGELOG +6 -0
- data/Rakefile +1 -1
- data/lib/scout_agent.rb +2 -2
- data/lib/scout_agent/server.rb +29 -3
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ SA_SPEC = Gem::Specification.new do |spec|
|
|
36
36
|
spec.require_path = "lib"
|
37
37
|
|
38
38
|
spec.add_dependency("arrayfields", "=4.7.3") # fix Amalgalite's results
|
39
|
-
spec.add_dependency("amalgalite", "=0.
|
39
|
+
spec.add_dependency("amalgalite", "=0.10.0")
|
40
40
|
spec.add_dependency("rest-client", "=1.0")
|
41
41
|
spec.add_dependency("json", "=1.1.6")
|
42
42
|
spec.add_dependency("xmpp4r", "=0.4")
|
data/lib/scout_agent.rb
CHANGED
@@ -28,7 +28,7 @@ require "scout_agent/api"
|
|
28
28
|
|
29
29
|
# require gems
|
30
30
|
require_lib_or_gem "json", "=1.1.6"
|
31
|
-
require_lib_or_gem "amalgalite", "=0.
|
31
|
+
require_lib_or_gem "amalgalite", "=0.10.0"
|
32
32
|
require_lib_or_gem "rest_client", "=1.0"
|
33
33
|
require_lib_or_gem "xmpp4r", "=0.4"
|
34
34
|
require_lib_or_gem "xmpp4r/roster" # loads from xmpp4r's version
|
@@ -92,7 +92,7 @@ module ScoutAgent
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# The version of this agent.
|
95
|
-
VERSION = "3.2.
|
95
|
+
VERSION = "3.2.6".freeze
|
96
96
|
# A Pathname reference to the agent code directory, used in dynamic loading.
|
97
97
|
LIB_DIR = Pathname.new(File.dirname(__FILE__)) + agent_name
|
98
98
|
end
|
data/lib/scout_agent/server.rb
CHANGED
@@ -7,6 +7,16 @@ module ScoutAgent
|
|
7
7
|
# Public methods are provided for each action you can perform againt the API.
|
8
8
|
#
|
9
9
|
class Server
|
10
|
+
# A custom Exception, used to avoid conflicts with Timeout::Error.
|
11
|
+
class AgentTimeoutError < RuntimeError; end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Another Timeout for Net::Http requests. Their limit doesn't always seem
|
15
|
+
# to trigger in the face of server errors, so we add this redundant check to
|
16
|
+
# avoid hanging on check-in.
|
17
|
+
#
|
18
|
+
REQUEST_TIMEOUT = 5 * 60
|
19
|
+
|
10
20
|
#
|
11
21
|
# Create a new API wrapper, optionally with a +log+ to write connection
|
12
22
|
# details to.
|
@@ -39,7 +49,7 @@ module ScoutAgent
|
|
39
49
|
# +nil+ is returned if the plan cannot be retrieved for some reason.
|
40
50
|
#
|
41
51
|
def get_plan(additional_headers = { })
|
42
|
-
|
52
|
+
request {
|
43
53
|
@rest_client["plan.scout"].get(additional_headers)
|
44
54
|
}
|
45
55
|
rescue Zlib::Error # could not decompress response
|
@@ -73,7 +83,7 @@ module ScoutAgent
|
|
73
83
|
gzip = Zlib::GzipWriter.new(io)
|
74
84
|
gzip << data.to_json
|
75
85
|
gzip.close
|
76
|
-
|
86
|
+
request do
|
77
87
|
@rest_client["checkin.scout"].post(
|
78
88
|
io.string,
|
79
89
|
:content_type => "application/json",
|
@@ -108,7 +118,7 @@ module ScoutAgent
|
|
108
118
|
# the upload succeeded.
|
109
119
|
#
|
110
120
|
def post_log(log_file)
|
111
|
-
|
121
|
+
request do
|
112
122
|
@rest_client["log.scout"].post(
|
113
123
|
log_file.read,
|
114
124
|
:content_type => "text/plain",
|
@@ -128,5 +138,21 @@ module ScoutAgent
|
|
128
138
|
log.warn("Log could not be sent: #{error.class}.")
|
129
139
|
false # could not send log
|
130
140
|
end
|
141
|
+
|
142
|
+
#######
|
143
|
+
private
|
144
|
+
#######
|
145
|
+
|
146
|
+
#
|
147
|
+
# A simple helper that silences some OpenSSL warnings and wraps the passed
|
148
|
+
# block in a +REQUEST_TIMEOUT+ limited execution.
|
149
|
+
#
|
150
|
+
def request
|
151
|
+
no_warnings { # keep OpenSSL quiet
|
152
|
+
Timeout.timeout(REQUEST_TIMEOUT, AgentTimeoutError) {
|
153
|
+
return yield
|
154
|
+
}
|
155
|
+
}
|
156
|
+
end
|
131
157
|
end
|
132
158
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Edward Gray II
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-06-
|
15
|
+
date: 2009-06-29 00:00:00 -05:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.10.0
|
37
37
|
version:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rest-client
|