stress_reporter 0.0.4 → 0.0.5
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/Rakefile +22 -1
- data/lib/stress_reporter/actions/free.rb +4 -5
- data/lib/stress_reporter/actions/xmanager.rb +12 -6
- data/lib/stress_reporter/checker.rb +7 -5
- data/lib/stress_reporter/version.rb +1 -1
- data/stress_reporter.gemspec +2 -1
- metadata +32 -3
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
|
@@ -8,3 +8,24 @@ end
|
|
8
8
|
|
9
9
|
desc "Run tests"
|
10
10
|
task :default => :test
|
11
|
+
|
12
|
+
require 'yard'
|
13
|
+
require 'yard/rake/yardoc_task'
|
14
|
+
|
15
|
+
project_root = File.expand_path(File.dirname(__FILE__))
|
16
|
+
doc_destination = File.join(project_root, 'doc')
|
17
|
+
|
18
|
+
YARD::Rake::YardocTask.new(:generate) do |yt|
|
19
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
20
|
+
[ File.join(project_root, 'README.md') ]
|
21
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
|
22
|
+
end
|
23
|
+
|
24
|
+
# Rake::RDocTask.new(:rdoc) do |rdoc|
|
25
|
+
# rdoc.rdoc_dir = 'doc'
|
26
|
+
# rdoc.main = 'README.md'
|
27
|
+
# # rdoc.rdoc_files.include 'README.md', 'CHANGELOG.txt', "config/**/*\.rb", "helpers/**/*\.rb", "script/**/*\.rb"
|
28
|
+
# rdoc.rdoc_files.include 'README.md', "lib/**/*\.rb"
|
29
|
+
# rdoc.options << '--line-numbers'
|
30
|
+
# rdoc.options << '--all'
|
31
|
+
# end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module StressReporter
|
2
2
|
module Actions
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# TODO:
|
6
|
-
# TODO: Spawning passenger-status is slow
|
3
|
+
# Returns output of free command
|
4
|
+
#
|
5
|
+
# TODO: Should read /proc directly
|
7
6
|
class Free
|
8
7
|
|
9
8
|
# Report returns a string array
|
@@ -12,4 +11,4 @@ module StressReporter
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
15
|
-
end
|
14
|
+
end
|
@@ -1,15 +1,22 @@
|
|
1
1
|
module StressReporter
|
2
|
+
# Classes under this namespace define specific things to do
|
3
|
+
# to include in reporting. They have to respond to #report with
|
4
|
+
# a string array.
|
2
5
|
module Actions
|
3
|
-
#
|
4
|
-
#
|
6
|
+
# Reports on passenger usage by calling passenger-status
|
7
|
+
# (pid and current request)
|
8
|
+
#
|
5
9
|
# TODO: We should not assume that xm_last_url_for_{pid} are in /tmp
|
6
|
-
#
|
10
|
+
#
|
11
|
+
# TODO: Spawning passenger-status is slow, probably we should include
|
12
|
+
# the passenger gem and use its methods.
|
7
13
|
class Xmanager
|
8
14
|
|
9
15
|
CMD = "passenger-status"
|
10
16
|
PID_REGEX = /PID:\s*(\d+)/
|
11
17
|
|
12
|
-
# Report
|
18
|
+
# Report lines
|
19
|
+
# @return [Array<String>]
|
13
20
|
def self.report
|
14
21
|
out = []
|
15
22
|
Xmanager.current_requests.each_pair do |pid, url|
|
@@ -30,8 +37,7 @@ module StressReporter
|
|
30
37
|
def self.current_requests
|
31
38
|
requests = {}
|
32
39
|
pids.each do |pid|
|
33
|
-
requests[pid] =
|
34
|
-
File.read("/tmp/xm_last_url_for_#{ pid }").chomp rescue "Not xmanager or fresh process"
|
40
|
+
requests[pid] = File.read("/tmp/xm_last_url_for_#{ pid }").chomp rescue "Not xmanager or fresh process"
|
35
41
|
end
|
36
42
|
requests
|
37
43
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# This class has the knowledge of when to run the reporting.
|
2
|
-
# It may well become a strategy, or a DSL parser
|
3
|
-
# being the check is very crude, just check last
|
2
|
+
# It may well become a strategy, or a DSL parser.
|
3
|
+
# For the time being the check is very crude, just check last minute load
|
4
4
|
# average
|
5
5
|
class StressReporter::Checker
|
6
6
|
|
7
|
-
# This limit
|
7
|
+
# This limit can be passed in as a command line arg
|
8
|
+
#
|
8
9
|
# Defaults to 1.0
|
9
|
-
LIMIT = ARGV.empty? ? 1 : ARGV[0].to_f
|
10
|
+
LIMIT = ARGV.empty? ? 1.0 : ARGV[0].to_f
|
10
11
|
|
11
12
|
# starts at 0.0
|
12
13
|
@@load_average = 0.0
|
@@ -17,7 +18,8 @@ class StressReporter::Checker
|
|
17
18
|
@@load_average > LIMIT
|
18
19
|
end
|
19
20
|
|
20
|
-
# Returns last load average
|
21
|
+
# Returns last checked load average
|
22
|
+
# @return [Float]
|
21
23
|
def self.load_average
|
22
24
|
@@load_average
|
23
25
|
end
|
data/stress_reporter.gemspec
CHANGED
@@ -18,9 +18,10 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_runtime_dependency 'sys-cpu'
|
21
|
-
# gem.add_runtime_dependency 'passenger'
|
22
21
|
gem.add_runtime_dependency 'SystemTimer'
|
23
22
|
|
24
23
|
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'yard'
|
25
|
+
gem.add_development_dependency 'redcarpet'
|
25
26
|
|
26
27
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stress_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcello Colacino
|
@@ -60,6 +60,34 @@ dependencies:
|
|
60
60
|
version: "0"
|
61
61
|
requirement: *id003
|
62
62
|
type: :development
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
prerelease: false
|
65
|
+
name: yard
|
66
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirement: *id004
|
76
|
+
type: :development
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
prerelease: false
|
79
|
+
name: redcarpet
|
80
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirement: *id005
|
90
|
+
type: :development
|
63
91
|
description: Daemon that runs and reports on stressful stuff
|
64
92
|
email:
|
65
93
|
- marcello.colacino@interact.it
|
@@ -119,3 +147,4 @@ specification_version: 3
|
|
119
147
|
summary: Was born with specific needs but may be extended to cover more scenarios
|
120
148
|
test_files:
|
121
149
|
- test/test_checker.rb
|
150
|
+
has_rdoc:
|