scout 5.8.6 → 5.8.7.pre
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.
- checksums.yaml +7 -0
- data/CHANGELOG.markdown +4 -0
- data/lib/scout/streamer.rb +24 -3
- data/lib/scout/streamer_daemon.rb +7 -5
- data/lib/scout/version.rb +1 -1
- data/test/streamer_test.rb +60 -0
- metadata +51 -73
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2bd2faad548e9481be7072ef0d517fa34204eb5c
|
4
|
+
data.tar.gz: edab687a4b73eaa562d900e6ba81b27859e40e3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed2efa5769da4f8648138e236e8dead6f1f707a2a4743c35cb8f4cc094a885f5be1cc43808a727bbc5b191f28f0d505a57e553e7e154a8fc32cdd124b71a8fa2
|
7
|
+
data.tar.gz: b90907cdbb9d16179fbb296e149f1a54a63260683de351bc047d23d092bd50bd2cad7b2d0dd16dd298fbba540ad2b9f8c79bd01fadc1d6c6c8700777d795e261
|
data/CHANGELOG.markdown
CHANGED
data/lib/scout/streamer.rb
CHANGED
@@ -9,7 +9,7 @@ module Scout
|
|
9
9
|
|
10
10
|
# * history_file is the *path* to the history file
|
11
11
|
# * plugin_ids is an array of integers
|
12
|
-
def initialize(history_file, streaming_key, p_app_id, p_key, p_secret, plugin_ids, hostname, http_proxy, logger = nil)
|
12
|
+
def initialize(history_file, streaming_key, p_app_id, p_key, p_secret, plugin_ids, system_metric_collectors, hostname, http_proxy, logger = nil)
|
13
13
|
@@continue_streaming = true
|
14
14
|
@history_file = history_file
|
15
15
|
@history = Hash.new
|
@@ -71,11 +71,32 @@ module Scout
|
|
71
71
|
:class=>plugin_hash['code_class']}
|
72
72
|
end
|
73
73
|
|
74
|
+
system_metric_data = {}
|
75
|
+
all_collectors = {:disk => ServerMetrics::Disk,
|
76
|
+
:cpu => ServerMetrics::Cpu,
|
77
|
+
:memory => ServerMetrics::Memory,
|
78
|
+
:network => ServerMetrics::Network,
|
79
|
+
:processes => ServerMetrics::Processes}
|
80
|
+
|
81
|
+
realtime_collectors = all_collectors.select { |key, klass| system_metric_collectors.include?(key) }
|
82
|
+
realtime_collectors.each_pair do |key, klass|
|
83
|
+
begin
|
84
|
+
collector_previous_run = @history[:server_metrics][key]
|
85
|
+
collector = collector_previous_run.is_a?(Hash) ? klass.from_hash(collector_previous_run) : klass.new() # continue with last run, or just create new
|
86
|
+
system_metric_data[key] = collector.run
|
87
|
+
@history[:server_metrics][key] = collector.to_hash # store its state for next time
|
88
|
+
rescue Exception => e
|
89
|
+
raise if e.is_a?(SystemExit)
|
90
|
+
error "Problem running server/#{key} metrics: #{e.message}: \n#{e.backtrace.join("\n")}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
74
94
|
bundle={:hostname=>hostname,
|
75
95
|
:server_time=>Time.now.strftime("%I:%M:%S %p"),
|
76
96
|
:server_unixtime => Time.now.to_i,
|
77
97
|
:num_processes=>`ps -e | wc -l`.chomp.to_i,
|
78
|
-
:plugins=>plugins
|
98
|
+
:plugins=>plugins,
|
99
|
+
:system_metrics => system_metric_data}
|
79
100
|
|
80
101
|
# stream the data via pusherapp
|
81
102
|
begin
|
@@ -199,4 +220,4 @@ module Scout
|
|
199
220
|
end
|
200
221
|
|
201
222
|
end
|
202
|
-
end
|
223
|
+
end
|
@@ -11,17 +11,19 @@ module Scout
|
|
11
11
|
:sync_log => true,
|
12
12
|
:working_dir => File.dirname(history_file)}
|
13
13
|
|
14
|
-
# streamer command might look like: start,A0000000000123,a,b,c,1,3
|
14
|
+
# streamer command might look like: start,A0000000000123,a,b,c,1,3,cpu,memory
|
15
15
|
tokens = streamer_command.split(",")
|
16
16
|
tokens.shift # gets rid of the "start"
|
17
17
|
streaming_key = tokens.shift
|
18
18
|
p_app_id = tokens.shift
|
19
19
|
p_key = tokens.shift
|
20
20
|
p_secret = tokens.shift
|
21
|
-
|
21
|
+
numerical_tokens = tokens.select { |token| token =~ /\A\d+\Z/ }
|
22
|
+
system_metric_collectors = (tokens - numerical_tokens).map(&:to_sym)
|
23
|
+
plugin_ids = numerical_tokens.map(&:to_i)
|
22
24
|
|
23
25
|
# we use STDOUT for the logger because daemon_spawn directs STDOUT to a log file
|
24
|
-
streamer_args = [history_file,streaming_key,p_app_id,p_key,p_secret,plugin_ids,hostname,http_proxy,Logger.new(STDOUT)]
|
26
|
+
streamer_args = [history_file,streaming_key,p_app_id,p_key,p_secret,plugin_ids,system_metric_collectors,hostname,http_proxy,Logger.new(STDOUT)]
|
25
27
|
if File.exists?(streamer_pid_file)
|
26
28
|
Scout::StreamerDaemon.restart(daemon_spawn_options, streamer_args)
|
27
29
|
else
|
@@ -45,8 +47,8 @@ module Scout
|
|
45
47
|
|
46
48
|
# this method is called by DaemonSpawn's class start method.
|
47
49
|
def start(streamer_args)
|
48
|
-
history,streaming_key,p_app_id,p_key,p_secret,plugin_ids,hostname,http_proxy,log = streamer_args
|
49
|
-
@scout = Scout::Streamer.new(history, streaming_key, p_app_id, p_key, p_secret, plugin_ids, hostname, http_proxy, log)
|
50
|
+
history,streaming_key,p_app_id,p_key,p_secret,plugin_ids,system_metric_collectors,hostname,http_proxy,log = streamer_args
|
51
|
+
@scout = Scout::Streamer.new(history, streaming_key, p_app_id, p_key, p_secret, plugin_ids, system_metric_collectors, hostname, http_proxy, log)
|
50
52
|
end
|
51
53
|
|
52
54
|
# this method is called by DaemonSpawn's class stop method.
|
data/lib/scout/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
begin
|
3
|
+
require 'pry'
|
4
|
+
rescue LoadError
|
5
|
+
# not using pry
|
6
|
+
end
|
7
|
+
# must be loaded after
|
8
|
+
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
|
9
|
+
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/..' )
|
10
|
+
require 'lib/scout'
|
11
|
+
require 'mocha/setup'
|
12
|
+
|
13
|
+
class StreamerTest < Test::Unit::TestCase
|
14
|
+
def test_reports_system_metrics
|
15
|
+
stub_history_file
|
16
|
+
plugin_ids_stub = []
|
17
|
+
system_metric_collectors = [:disk]
|
18
|
+
|
19
|
+
mock_pusher do
|
20
|
+
streamer = Scout::Streamer.new(:history_file_stub, :streaming_key_stub, :pusher_app_id_stub, :pusher_key_stub, :pusher_secret_stub, plugin_ids_stub, system_metric_collectors, :hostname_stub, :http_proxy_stub)
|
21
|
+
end
|
22
|
+
|
23
|
+
response = Pusher::Channel.streamer_data.first
|
24
|
+
assert_equal [:disk], response[:system_metrics].keys
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def stub_history_file
|
30
|
+
File.stubs(:read).with(:history_file_stub).returns(YAML.dump({:server_metrics => {}}))
|
31
|
+
File.stubs(:dirname).with(:history_file_stub).returns('tmp')
|
32
|
+
end
|
33
|
+
|
34
|
+
# this with a block to mock the pusher call. You can access the streamer data through the Pusher::Channel.streamer_data
|
35
|
+
# Must be called with a code block
|
36
|
+
def mock_pusher(num_runs=1)
|
37
|
+
# redefine the trigger! method, so the streamer doesn't loop indefinitely. We can't just mock it, because
|
38
|
+
# we need to set the $continue_streaming=false
|
39
|
+
$num_runs_for_mock_pusher=num_runs
|
40
|
+
Pusher::Channel.module_eval do
|
41
|
+
alias orig_trigger! trigger!
|
42
|
+
def self.streamer_data;@@streamer_data;end # for getting the data back out
|
43
|
+
def trigger!(event_name, data, socket=nil)
|
44
|
+
$num_run_for_tests = $num_run_for_tests ? $num_run_for_tests+1 : 1
|
45
|
+
@@streamer_data_temp ||= Array.new
|
46
|
+
@@streamer_data_temp << data
|
47
|
+
if $num_run_for_tests >= $num_runs_for_mock_pusher
|
48
|
+
Scout::Streamer.continue_streaming=false
|
49
|
+
$num_run_for_tests=nil
|
50
|
+
@@streamer_data = @@streamer_data_temp.clone
|
51
|
+
@@streamer_data_temp = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
yield # must be called with a block
|
56
|
+
Pusher::Channel.module_eval do
|
57
|
+
alias trigger! orig_trigger!
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -1,66 +1,53 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 5
|
8
|
-
- 8
|
9
|
-
- 6
|
10
|
-
version: 5.8.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 5.8.7.pre
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Andre Lewis
|
14
8
|
- Derek Haynes
|
15
9
|
- James Edward Gray II
|
16
10
|
autorequire:
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
24
16
|
name: elif
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
hash: 3
|
32
|
-
segments:
|
33
|
-
- 0
|
34
|
-
version: "0"
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: server_metrics
|
39
23
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: server_metrics
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
50
35
|
version: 1.2.0
|
51
36
|
type: :runtime
|
52
|
-
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.2.0
|
53
43
|
description: |
|
54
44
|
The scout gem reports metrics to scoutapp.com, an easy-to-use hosted server monitoring service.
|
55
|
-
|
56
45
|
email: support@scoutapp.com
|
57
|
-
executables:
|
46
|
+
executables:
|
58
47
|
- scout
|
59
48
|
extensions: []
|
60
|
-
|
61
49
|
extra_rdoc_files: []
|
62
|
-
|
63
|
-
files:
|
50
|
+
files:
|
64
51
|
- .gitignore
|
65
52
|
- CHANGELOG.markdown
|
66
53
|
- Gemfile
|
@@ -94,6 +81,7 @@ files:
|
|
94
81
|
- scout.gemspec
|
95
82
|
- test/plugins/disk_usage.rb
|
96
83
|
- test/scout_test.rb
|
84
|
+
- test/streamer_test.rb
|
97
85
|
- vendor/httpclient/README.txt
|
98
86
|
- vendor/httpclient/bin/httpclient
|
99
87
|
- vendor/httpclient/lib/hexdump.rb
|
@@ -323,40 +311,30 @@ files:
|
|
323
311
|
- vendor/signature/spec/signature_spec.rb
|
324
312
|
- vendor/signature/spec/spec_helper.rb
|
325
313
|
- vendor/util/lib/core_extensions.rb
|
326
|
-
has_rdoc: true
|
327
314
|
homepage: http://scoutapp.com
|
328
315
|
licenses: []
|
329
|
-
|
316
|
+
metadata: {}
|
330
317
|
post_install_message:
|
331
318
|
rdoc_options: []
|
332
|
-
|
333
|
-
require_paths:
|
319
|
+
require_paths:
|
334
320
|
- lib
|
335
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
none: false
|
346
|
-
requirements:
|
347
|
-
- - ">="
|
348
|
-
- !ruby/object:Gem::Version
|
349
|
-
hash: 3
|
350
|
-
segments:
|
351
|
-
- 0
|
352
|
-
version: "0"
|
321
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
322
|
+
requirements:
|
323
|
+
- - '>='
|
324
|
+
- !ruby/object:Gem::Version
|
325
|
+
version: '0'
|
326
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
327
|
+
requirements:
|
328
|
+
- - '>'
|
329
|
+
- !ruby/object:Gem::Version
|
330
|
+
version: 1.3.1
|
353
331
|
requirements: []
|
354
|
-
|
355
332
|
rubyforge_project: scout
|
356
|
-
rubygems_version: 1.
|
333
|
+
rubygems_version: 2.1.9
|
357
334
|
signing_key:
|
358
|
-
specification_version:
|
359
|
-
summary: Scout is an easy-to-use hosted server monitoring service. The scout Ruby
|
360
|
-
|
361
|
-
|
362
|
-
|
335
|
+
specification_version: 4
|
336
|
+
summary: Scout is an easy-to-use hosted server monitoring service. The scout Ruby
|
337
|
+
gem reports metrics to our service. The agent runs plugins, configured via the Scout
|
338
|
+
web interface, to monitor a server.
|
339
|
+
test_files: []
|
340
|
+
has_rdoc:
|