stress_reporter 0.0.2 → 0.0.3
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/bin/stress_reporter
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
require 'stress_reporter'
|
4
4
|
require 'stress_reporter/checker'
|
5
5
|
require 'stress_reporter/actions/xmanager'
|
6
|
+
require 'stress_reporter/actions/free'
|
6
7
|
|
7
8
|
@_logger = Logger.new("/var/log/stress_report/monitor.log")
|
8
|
-
puts "Going to trigger when load average exceeds #{StressReporter::Checker::LIMIT}"
|
9
|
+
puts "Going to trigger when load average exceeds #{ StressReporter::Checker::LIMIT }"
|
10
|
+
VERBOSE = true
|
9
11
|
|
12
|
+
# Define out own exception to raise in main loop
|
10
13
|
class MyTimeoutException < Exception ; end
|
11
14
|
|
12
15
|
# Initial delay between checks
|
@@ -14,7 +17,7 @@ class MyTimeoutException < Exception ; end
|
|
14
17
|
|
15
18
|
def log severity, msg
|
16
19
|
@_logger.send severity, msg
|
17
|
-
puts "#{ severity }: #{ msg }"
|
20
|
+
puts "#{ severity }: #{ msg }" if VERBOSE
|
18
21
|
end
|
19
22
|
|
20
23
|
|
@@ -24,9 +27,14 @@ while true do
|
|
24
27
|
SystemTimer.timeout_after(StressReporter::TIMEOUT, MyTimeoutException) do
|
25
28
|
if StressReporter::Checker.go?
|
26
29
|
log(:warn, "Load average of #{ StressReporter::Checker::LIMIT } Exceeded: (#{ StressReporter::Checker.load_average }) - running checks")
|
30
|
+
log(:info, "**** Xmanager ****")
|
27
31
|
StressReporter::Actions::Xmanager.report.each {|l|
|
28
32
|
log(:info, l)
|
29
33
|
}
|
34
|
+
log(:info, "**** Free ****")
|
35
|
+
StressReporter::Actions::Free.report.each {|l|
|
36
|
+
log(:info, l)
|
37
|
+
}
|
30
38
|
end
|
31
39
|
end
|
32
40
|
@delay = @delay - 1.0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module StressReporter
|
2
|
+
module Actions
|
3
|
+
# Actions to report on passenger usage.
|
4
|
+
# Current requests, urls, pids
|
5
|
+
# TODO: We should not assume that xm_last_url_for_{pid} are in /tmp
|
6
|
+
# TODO: Spawning passenger-status is slow
|
7
|
+
class Free
|
8
|
+
|
9
|
+
# Report returns a string array
|
10
|
+
def self.report
|
11
|
+
`free`.map(&:chomp)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -22,30 +22,18 @@ module StressReporter
|
|
22
22
|
|
23
23
|
# Returns array of pids of current passenger processes
|
24
24
|
def self.pids
|
25
|
-
|
26
|
-
p
|
27
|
-
while !p.eof?
|
28
|
-
line = p.readpartial(1024)
|
29
|
-
m = line.scan PID_REGEX
|
30
|
-
pids = m.flatten
|
31
|
-
end
|
32
|
-
pids
|
25
|
+
p = `#{ CMD }`
|
26
|
+
p.scan(PID_REGEX).flatten
|
33
27
|
end
|
34
28
|
|
35
29
|
# Returns hash { pid => url }
|
36
30
|
def self.current_requests
|
37
31
|
requests = {}
|
38
32
|
pids.each do |pid|
|
39
|
-
|
40
|
-
p = IO.popen("cat /tmp/xm_last_url_for_#{pid}")
|
41
|
-
while !p.eof?
|
42
|
-
requests[pid] = p.readpartial(1024).chomp
|
43
|
-
end
|
44
|
-
end
|
33
|
+
requests[pid] = File.read("/tmp/xm_last_url_for_#{ pid }").chomp
|
45
34
|
end
|
46
35
|
requests
|
47
36
|
end
|
48
|
-
|
49
37
|
end
|
50
38
|
end
|
51
39
|
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: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcello Colacino
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-10-
|
19
|
+
date: 2012-10-24 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
prerelease: false
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- Rakefile
|
79
79
|
- bin/stress_reporter
|
80
80
|
- lib/stress_reporter.rb
|
81
|
+
- lib/stress_reporter/actions/free.rb
|
81
82
|
- lib/stress_reporter/actions/xmanager.rb
|
82
83
|
- lib/stress_reporter/checker.rb
|
83
84
|
- lib/stress_reporter/version.rb
|