scout 5.0.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/lib/scout/command/install.rb +4 -1
- data/lib/scout/command.rb +1 -1
- data/lib/scout/plugin.rb +46 -0
- data/lib/scout/server.rb +2 -2
- data/lib/scout.rb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 5.1.0
|
2
|
+
|
3
|
+
* Agent now reports data on initial install
|
4
|
+
* If history file is empty, Agent will resume normal checkin when it can write history file again (thx @jnewland)
|
5
|
+
* inclusion of counter functionality (thx @lindvall)
|
6
|
+
|
1
7
|
== 5.0.3
|
2
8
|
|
3
9
|
* fixed regression: Error when running `scout AGENT_KEY` without first running scout and manually entering the agent key
|
@@ -22,7 +22,10 @@ module Scout
|
|
22
22
|
|
23
23
|
puts "\nAttempting to contact the server..."
|
24
24
|
begin
|
25
|
-
Scout::Server.new(server, key, history, log)
|
25
|
+
Scout::Server.new(server, key, history, log) do |scout|
|
26
|
+
scout.fetch_plan
|
27
|
+
scout.run_plugins_by_plan
|
28
|
+
end
|
26
29
|
|
27
30
|
puts <<-END_SUCCESS.gsub(/^ {10}/, "")
|
28
31
|
Success!
|
data/lib/scout/command.rb
CHANGED
@@ -218,7 +218,7 @@ module Scout
|
|
218
218
|
if running
|
219
219
|
if pid == "unknown"
|
220
220
|
log.warn "Could not create or read PID file. " +
|
221
|
-
"You may need to the path to the config directory. " +
|
221
|
+
"You may need to specify the path to the config directory. " +
|
222
222
|
"See: http://scoutapp.com/help#data_file" if log
|
223
223
|
else
|
224
224
|
log.warn "Process #{pid} was already running" if log
|
data/lib/scout/plugin.rb
CHANGED
@@ -155,6 +155,52 @@ module Scout
|
|
155
155
|
(0...other.size).step(2) { |i| memory.merge!(other[i] => other[i + 1]) }
|
156
156
|
end
|
157
157
|
|
158
|
+
#
|
159
|
+
# Usage:
|
160
|
+
#
|
161
|
+
# counter(:rkbps, stats['rsect'] / 2, :per => :second)
|
162
|
+
# counter(:rpm, request_counter, :per => :minute)
|
163
|
+
# counter(:swap_ins, vmstat['pswpin'], :per => :second, :round => true)
|
164
|
+
#
|
165
|
+
def counter(name, value, options = {}, &block)
|
166
|
+
current_time = Time.now
|
167
|
+
|
168
|
+
if data = memory("_counter_#{name}")
|
169
|
+
last_time, last_value = data[:time], data[:value]
|
170
|
+
elapsed_seconds = current_time - last_time
|
171
|
+
|
172
|
+
# We won't log it if the value has wrapped or enough time hasn't
|
173
|
+
# elapsed
|
174
|
+
if value >= last_value && elapsed_seconds >= 1
|
175
|
+
if block
|
176
|
+
result = block.call(last_value, value)
|
177
|
+
else
|
178
|
+
result = value - last_value
|
179
|
+
end
|
180
|
+
|
181
|
+
case options[:per]
|
182
|
+
when :second, 'second'
|
183
|
+
result = result / elapsed_seconds.to_f
|
184
|
+
when :minute, 'minute'
|
185
|
+
result = result / elapsed_seconds.to_f / 60.0
|
186
|
+
else
|
187
|
+
raise "Unknown option for ':per': #{options[:per].inspect}"
|
188
|
+
end
|
189
|
+
|
190
|
+
if options[:round]
|
191
|
+
# Backward compatibility
|
192
|
+
options[:round] = 1 if options[:round] == true
|
193
|
+
|
194
|
+
result = (result * (10 ** options[:round])).round / (10 ** options[:round]).to_f
|
195
|
+
end
|
196
|
+
|
197
|
+
report(name => result)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
remember("_counter_#{name}" => { :time => current_time, :value => value })
|
202
|
+
end
|
203
|
+
|
158
204
|
#
|
159
205
|
# Old plugins will work because they override this method. New plugins can
|
160
206
|
# now leave this method in place, add a build_report() method instead, and
|
data/lib/scout/server.rb
CHANGED
@@ -67,7 +67,7 @@ module Scout
|
|
67
67
|
def fetch_plan
|
68
68
|
url = urlify(:plan)
|
69
69
|
info "Pinging server at #{url}..."
|
70
|
-
headers =
|
70
|
+
headers = {"x_scout_tty" => ($stdin.tty? ? 'true' : 'false')}
|
71
71
|
if @history["plan_last_modified"] and @history["old_plugins"]
|
72
72
|
headers["If-Modified-Since"] = @history["plan_last_modified"]
|
73
73
|
end
|
@@ -291,7 +291,7 @@ module Scout
|
|
291
291
|
# it creates one.
|
292
292
|
#
|
293
293
|
def load_history
|
294
|
-
|
294
|
+
if !File.exist?(@history_file) || File.zero?(@history_file)
|
295
295
|
create_blank_history
|
296
296
|
end
|
297
297
|
debug "Loading history file..."
|
data/lib/scout.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Highgroove Studios
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-23 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|