oink 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +0 -1
- data/README.rdoc +25 -8
- data/Rakefile +1 -2
- data/lib/oink/middleware.rb +33 -20
- data/lib/oink/reports/active_record_instantiation_report.rb +2 -2
- data/lib/oink/reports/memory_usage_report.rb +2 -2
- data/spec/oink/middleware_configuration_spec.rb +65 -0
- data/spec/oink/middleware_spec.rb +11 -12
- data/spec/oink/reports/active_record_instantiation_report_spec.rb +41 -41
- data/spec/oink/reports/memory_usage_report_spec.rb +76 -76
- metadata +6 -18
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -32,23 +32,37 @@ Add oink to your Gemfile
|
|
32
32
|
|
33
33
|
gem "oink"
|
34
34
|
|
35
|
-
In most rails environments this is sufficient and oink will be required for you via bundler.
|
35
|
+
In most rails environments this is sufficient and oink will be required for you via bundler.
|
36
|
+
If not, add a require statement "require 'oink'" in your app.
|
36
37
|
|
37
38
|
=== Configuration
|
38
39
|
|
39
40
|
Oink is middleware for instrumentation during the runtime of your application as well as log parsers for offline crunching of the logs generated by
|
40
41
|
the middleware.
|
41
42
|
|
42
|
-
The middleware class to include into your stack is "Oink::Middleware".
|
43
|
-
application.rb or environment.rb file:
|
43
|
+
The middleware class to include into your stack is "Oink::Middleware". For rails using an initializer is recommended:
|
44
44
|
|
45
|
-
|
45
|
+
YourApplication::Application.middleware.use Oink::Middleware
|
46
46
|
|
47
|
-
|
47
|
+
Oink::Middleware writes log entries to log/oink.log in your application root directory by default.
|
48
48
|
|
49
|
-
|
49
|
+
You can also initialize it with an optional logger instance enabling your application to write Oink log entries to your application's default log file:
|
50
50
|
|
51
|
-
|
51
|
+
YourApplication::Application.middleware.use( Oink::Middleware, :logger => Rails.logger )
|
52
|
+
|
53
|
+
(This setup enables Oink to work with Request Log Analyzer (https://github.com/wvanbergen/request-log-analyzer), which currently parses rails logs)
|
54
|
+
|
55
|
+
Oink::Middleware logs memory and activerecord usage by default.
|
56
|
+
|
57
|
+
You can configure which using the :instruments option. For memory only:
|
58
|
+
|
59
|
+
YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :memory )
|
60
|
+
|
61
|
+
For activerecord instantiation counts only:
|
62
|
+
|
63
|
+
YourApplication::Application.middleware.use( Oink::Middleware, :instruments => :activerecord )
|
64
|
+
|
65
|
+
Note that the previous way of configuring oink, as a set of modules to include into rails controllers, is deprecated.
|
52
66
|
|
53
67
|
== Analyzing logs
|
54
68
|
|
@@ -106,12 +120,15 @@ e.g. In verbose mode, oink will print out all the log information from your logs
|
|
106
120
|
$ oink --format verbose --threshold=75 /tmp/logs/*
|
107
121
|
|
108
122
|
---------------------------------------------------------------------
|
123
|
+
|
109
124
|
Feb 08 11:39:52 ey33-s00302 rails[9076]: Processing UsersController#show (for 11.187.34.45 at 2009-02-08 11:39:52) [GET]
|
110
125
|
Feb 08 11:39:52 ey33-s00302 rails[9076]: Parameters: {"action"=>"show", "id"=>"45", "controller"=>"users"}
|
111
126
|
Feb 08 11:39:52 ey33-s00302 rails[9076]: Rendering template within layouts/application
|
112
127
|
Feb 08 11:39:52 ey33-s00302 rails[9076]: Rendering users/show
|
113
|
-
Feb 08 11:39:54 ey33-s00302 rails[9076]: Memory usage: 316516 | PID: 9076
|
114
128
|
Feb 08 11:39:54 ey33-s00302 rails[9076]: Completed in 2008ms (View: 1136, DB: 264) | 200 OK [http://www.example.com/users/45]
|
129
|
+
Feb 08 11:39:52 ey33-s00302 rails[9076]: Oink Action: users#show
|
130
|
+
Feb 08 11:39:54 ey33-s00302 rails[9076]: Memory usage: 316516 | PID: 9076
|
131
|
+
Feb 08 11:39:54 ey33-s00302 rails[9076]: Oink Log Entry Complete
|
115
132
|
---------------------------------------------------------------------
|
116
133
|
|
117
134
|
Verbose format prints the summary as well as each action which exceeded the threshold.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
require 'jeweler'
|
7
7
|
Jeweler::Tasks.new do |s|
|
8
8
|
s.name = "oink"
|
9
|
-
s.version = "0.9.
|
9
|
+
s.version = "0.9.2"
|
10
10
|
s.author = "Noah Davis"
|
11
11
|
s.email = "noahd1" + "@" + "yahoo.com"
|
12
12
|
s.homepage = "http://github.com/noahd1/oink"
|
@@ -14,7 +14,6 @@ begin
|
|
14
14
|
s.description = s.summary
|
15
15
|
s.executables = "oink"
|
16
16
|
s.files = %w[History.txt MIT-LICENSE README.rdoc Rakefile] + Dir["bin/*"] + Dir["lib/**/*"]
|
17
|
-
s.add_dependency 'hodel_3000_compliant_logger'
|
18
17
|
end
|
19
18
|
Jeweler::GemcutterTasks.new
|
20
19
|
rescue LoadError
|
data/lib/oink/middleware.rb
CHANGED
@@ -5,44 +5,57 @@ require 'oink/instrumentation'
|
|
5
5
|
module Oink
|
6
6
|
class Middleware
|
7
7
|
|
8
|
-
def initialize(app,
|
9
|
-
|
10
|
-
@logger
|
11
|
-
@
|
8
|
+
def initialize(app, options = {})
|
9
|
+
@app = app
|
10
|
+
@logger = options[:logger] || Hodel3000CompliantLogger.new("log/oink.log")
|
11
|
+
@instruments = options[:instruments] ? Array(options[:instruments]) : [:memory, :activerecord]
|
12
|
+
|
13
|
+
ActiveRecord::Base.send(:include, Oink::Instrumentation::ActiveRecord) if @instruments.include?(:activerecord)
|
12
14
|
end
|
13
15
|
|
14
16
|
def call(env)
|
15
17
|
status, headers, body = @app.call(env)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
log_routing(env)
|
20
|
+
log_memory
|
21
|
+
log_activerecord
|
22
|
+
log_completed
|
21
23
|
[status, headers, body]
|
22
24
|
end
|
23
25
|
|
24
|
-
def
|
26
|
+
def log_completed
|
27
|
+
@logger.info("Oink Log Entry Complete")
|
28
|
+
end
|
29
|
+
|
30
|
+
def log_routing(env)
|
25
31
|
if env.has_key?('action_dispatch.request.parameters')
|
26
32
|
controller = env['action_dispatch.request.parameters']['controller']
|
27
|
-
action
|
28
|
-
@logger.info
|
33
|
+
action = env['action_dispatch.request.parameters']['action']
|
34
|
+
@logger.info("Oink Action: #{controller}##{action}")
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
38
|
+
def log_memory
|
39
|
+
if @instruments.include?(:memory)
|
40
|
+
memory = Oink::Instrumentation::MemorySnapshot.memory
|
41
|
+
@logger.info("Memory usage: #{memory} | PID: #{$$}")
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
45
|
+
def log_activerecord
|
46
|
+
if @instruments.include?(:activerecord)
|
47
|
+
sorted_list = Oink::HashUtils.to_sorted_array(ActiveRecord::Base.instantiated_hash)
|
48
|
+
sorted_list.unshift("Total: #{ActiveRecord::Base.total_objects_instantiated}")
|
49
|
+
@logger.info("Instantiation Breakdown: #{sorted_list.join(' | ')}")
|
50
|
+
reset_objects_instantiated
|
51
|
+
end
|
41
52
|
end
|
42
53
|
|
54
|
+
private
|
55
|
+
|
43
56
|
def reset_objects_instantiated
|
44
57
|
ActiveRecord::Base.reset_instance_type_count
|
45
58
|
end
|
46
59
|
|
47
60
|
end
|
48
|
-
end
|
61
|
+
end
|
@@ -26,7 +26,7 @@ module Oink
|
|
26
26
|
@pids[pid][:buffer] << line
|
27
27
|
end
|
28
28
|
|
29
|
-
if line =~ /
|
29
|
+
if line =~ /Oink Action: ((\w+)#(\w+))/
|
30
30
|
|
31
31
|
@pids[pid][:action] = $1
|
32
32
|
unless @pids[pid][:request_finished]
|
@@ -38,7 +38,7 @@ module Oink
|
|
38
38
|
|
39
39
|
@pids[pid][:ar_count] = $1.to_i
|
40
40
|
|
41
|
-
elsif line =~ /
|
41
|
+
elsif line =~ /Oink Log Entry Complete/
|
42
42
|
|
43
43
|
if @pids[pid][:ar_count] > @threshold
|
44
44
|
@bad_actions[@pids[pid][:action]] ||= 0
|
@@ -25,7 +25,7 @@ module Oink
|
|
25
25
|
@pids[pid][:buffer] << line
|
26
26
|
end
|
27
27
|
|
28
|
-
if line =~ /
|
28
|
+
if line =~ /Oink Action: ((\w+)#(\w+))/
|
29
29
|
|
30
30
|
unless @pids[pid][:request_finished]
|
31
31
|
@pids[pid][:last_memory_reading] = -1
|
@@ -38,7 +38,7 @@ module Oink
|
|
38
38
|
memory_reading = $1.to_i
|
39
39
|
@pids[pid][:current_memory_reading] = memory_reading
|
40
40
|
|
41
|
-
elsif line =~ /
|
41
|
+
elsif line =~ /Oink Log Entry Complete/
|
42
42
|
|
43
43
|
@pids[pid][:request_finished] = true
|
44
44
|
unless @pids[pid][:current_memory_reading] == -1 || @pids[pid][:last_memory_reading] == -1
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require "oink/middleware"
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
describe "Oink::Middleware configuration" do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
class SampleApplication
|
9
|
+
def call(env)
|
10
|
+
[200, {}, ""]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:app) { Oink::Middleware.new(SampleApplication.new, oink_configuration) }
|
15
|
+
let(:oink_configuration) { @oink_configuration || {} }
|
16
|
+
|
17
|
+
context "instruments options" do
|
18
|
+
before do
|
19
|
+
@log_output = StringIO.new
|
20
|
+
Hodel3000CompliantLogger.stub(:new => Hodel3000CompliantLogger.new(@log_output))
|
21
|
+
Oink::Instrumentation::MemorySnapshot.stub(:memory => 4092)
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with the memory instrument specified" do
|
25
|
+
before do
|
26
|
+
@oink_configuration = { :instruments => :memory }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does log memory usage" do
|
30
|
+
get "/"
|
31
|
+
@log_output.string.should include("Memory usage: 4092 | PID: #{$$}")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does not log activerecord objects instantiated" do
|
35
|
+
get "/"
|
36
|
+
@log_output.string.should_not include("Instantiation Breakdown:")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "does not monkeypatch activerecord" do
|
40
|
+
ActiveRecord::Base.should_not_receive(:include)
|
41
|
+
get "/"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "does not call reset_instance_type_count" do
|
45
|
+
ActiveRecord::Base.should_not_receive(:reset_instance_type_count)
|
46
|
+
get "/"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "with the activerecord instrument specified" do
|
51
|
+
before do
|
52
|
+
@oink_configuration = { :instruments => :activerecord }
|
53
|
+
get "/"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "does not log memory usage" do
|
57
|
+
@log_output.string.should_not include("Memory usage:")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "does log activerecord objects instantiated" do
|
61
|
+
@log_output.string.should include("Instantiation Breakdown:")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -21,53 +21,52 @@ describe Oink::Middleware do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
let(:
|
24
|
+
let(:log_output) { StringIO.new }
|
25
|
+
let(:logger) { Hodel3000CompliantLogger.new(log_output) }
|
26
|
+
let(:app) { Oink::Middleware.new(SampleApplication.new, :logger => logger) }
|
25
27
|
|
26
28
|
before do
|
27
|
-
@log_output = StringIO.new
|
28
|
-
Hodel3000CompliantLogger.stub(:new => Hodel3000CompliantLogger.new(@log_output))
|
29
29
|
Oink::Instrumentation::MemorySnapshot.stub(:memory => 4092)
|
30
30
|
Pig.delete_all
|
31
31
|
Pen.delete_all
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
34
|
context "support legacy rails log format in transition to oink's own log format" do
|
36
35
|
it "writes rails[pid] to the log even if the app isn't a rails app (for now)" do
|
37
36
|
get "/no_pigs"
|
38
|
-
|
37
|
+
log_output.string.should include("rails[#{$$}]")
|
39
38
|
end
|
40
39
|
|
41
|
-
it "writes '
|
40
|
+
it "writes 'Oink Log Entry Complete' after the request has completed" do
|
42
41
|
get "/no_pigs"
|
43
|
-
|
42
|
+
log_output.string.should include("Oink Log Entry Complete")
|
44
43
|
end
|
45
44
|
|
46
45
|
it "logs the action and controller" do
|
47
46
|
get "/no_pigs", {}, {'action_dispatch.request.parameters' => {'controller' => 'oinkoink', 'action' => 'piggie'}}
|
48
|
-
|
47
|
+
log_output.string.should include("Oink Action: oinkoink#piggie")
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
it "reports 0 totals" do
|
53
52
|
get "/no_pigs"
|
54
|
-
|
53
|
+
log_output.string.should include("Instantiation Breakdown: Total: 0")
|
55
54
|
end
|
56
55
|
|
57
56
|
it "reports totals first even if it's a tie" do
|
58
57
|
get "/two_pigs"
|
59
|
-
|
58
|
+
log_output.string.should include("Instantiation Breakdown: Total: 2 | Pig: 2")
|
60
59
|
end
|
61
60
|
|
62
61
|
it "reports pigs and pens instantiated" do
|
63
62
|
get "/two_pigs_in_a_pen"
|
64
|
-
|
63
|
+
log_output.string.should include("Instantiation Breakdown: Total: 3 | Pig: 2 | Pen: 1")
|
65
64
|
end
|
66
65
|
|
67
66
|
it "logs memory usage" do
|
68
67
|
Oink::Instrumentation::MemorySnapshot.should_receive(:memory).and_return(4092)
|
69
68
|
get "/two_pigs_in_a_pen"
|
70
|
-
|
69
|
+
log_output.string.should include("Memory usage: 4092 | PID: #{$$}")
|
71
70
|
end
|
72
71
|
|
73
72
|
end
|
@@ -7,9 +7,9 @@ module Oink::Reports
|
|
7
7
|
|
8
8
|
it "should report actions which exceed the threshold once" do
|
9
9
|
str = <<-STR
|
10
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
10
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
11
11
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
12
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
12
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
13
13
|
STR
|
14
14
|
|
15
15
|
io = StringIO.new(str)
|
@@ -20,9 +20,9 @@ module Oink::Reports
|
|
20
20
|
|
21
21
|
it "should not report actions which do not exceed the threshold" do
|
22
22
|
str = <<-STR
|
23
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
23
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
24
24
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 50 | User: 50
|
25
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
25
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
26
26
|
STR
|
27
27
|
|
28
28
|
io = StringIO.new(str)
|
@@ -33,12 +33,12 @@ module Oink::Reports
|
|
33
33
|
|
34
34
|
it "should report actions which exceed the threshold multiple times" do
|
35
35
|
str = <<-STR
|
36
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
36
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
37
37
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
38
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
39
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
38
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
39
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
40
40
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
41
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
41
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
42
42
|
STR
|
43
43
|
|
44
44
|
io = StringIO.new(str)
|
@@ -49,15 +49,15 @@ module Oink::Reports
|
|
49
49
|
|
50
50
|
it "should order actions by most exceeded" do
|
51
51
|
str = <<-STR
|
52
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
52
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
53
53
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
54
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
55
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
54
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
55
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
56
56
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
57
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
58
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
57
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
58
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
59
59
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
60
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
60
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
61
61
|
STR
|
62
62
|
|
63
63
|
io = StringIO.new(str)
|
@@ -69,13 +69,13 @@ module Oink::Reports
|
|
69
69
|
|
70
70
|
it "should not be bothered by incomplete requests" do
|
71
71
|
str = <<-STR
|
72
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
72
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
73
73
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 24 | User: 24
|
74
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
75
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
76
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
74
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
75
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
76
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
77
77
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
78
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
78
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
79
79
|
STR
|
80
80
|
|
81
81
|
io = StringIO.new(str)
|
@@ -90,9 +90,9 @@ module Oink::Reports
|
|
90
90
|
|
91
91
|
it "should only report requests over threshold" do
|
92
92
|
str = <<-STR
|
93
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
93
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
94
94
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
95
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
95
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
96
96
|
STR
|
97
97
|
|
98
98
|
io = StringIO.new(str)
|
@@ -103,9 +103,9 @@ module Oink::Reports
|
|
103
103
|
|
104
104
|
it "should not include requests which are not over threshold" do
|
105
105
|
str = <<-STR
|
106
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
106
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
107
107
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 50 | User: 50
|
108
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
108
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
109
109
|
STR
|
110
110
|
|
111
111
|
io = StringIO.new(str)
|
@@ -116,19 +116,19 @@ module Oink::Reports
|
|
116
116
|
|
117
117
|
it "should order offenses from biggest to smallest" do
|
118
118
|
str = <<-STR
|
119
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
119
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Details#show
|
120
120
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 75 | User: 75
|
121
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
122
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
121
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
122
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
123
123
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
|
124
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
124
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
125
125
|
STR
|
126
126
|
|
127
127
|
io = StringIO.new(str)
|
128
128
|
output = PsuedoOutput.new
|
129
129
|
ActiveRecordInstantiationReport.new(io, 50).print(output)
|
130
|
-
output[4].should == "1. Feb 01 01:58:34, 100,
|
131
|
-
output[5].should == "2. Feb 01 01:58:31, 75,
|
130
|
+
output[4].should == "1. Feb 01 01:58:34, 100, Media#show"
|
131
|
+
output[5].should == "2. Feb 01 01:58:31, 75, Details#show"
|
132
132
|
end
|
133
133
|
|
134
134
|
end
|
@@ -136,9 +136,9 @@ module Oink::Reports
|
|
136
136
|
describe "verbose format" do
|
137
137
|
it "should print the full lines of actions exceeding the threshold" do
|
138
138
|
str = <<-STR
|
139
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
139
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
140
140
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
|
141
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
141
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
142
142
|
STR
|
143
143
|
io = StringIO.new(str)
|
144
144
|
output = PsuedoOutput.new
|
@@ -148,13 +148,13 @@ module Oink::Reports
|
|
148
148
|
|
149
149
|
it "should handle actions which do not complete properly" do
|
150
150
|
str = <<-STR
|
151
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
151
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
152
152
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 24 | User: 24
|
153
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
154
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
155
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
153
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
154
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
155
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
156
156
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
|
157
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
157
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
158
158
|
STR
|
159
159
|
|
160
160
|
io = StringIO.new(str)
|
@@ -168,22 +168,22 @@ module Oink::Reports
|
|
168
168
|
it "should accept multiple files" do
|
169
169
|
|
170
170
|
str1 = <<-STR
|
171
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
171
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
172
172
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
|
173
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
173
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
174
174
|
STR
|
175
175
|
|
176
176
|
str2 = <<-STR
|
177
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
177
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
178
178
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
|
179
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
179
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
180
180
|
STR
|
181
181
|
|
182
182
|
io1 = StringIO.new(str1)
|
183
183
|
io2 = StringIO.new(str2)
|
184
184
|
output = PsuedoOutput.new
|
185
185
|
ActiveRecordInstantiationReport.new([io1, io2], 50).print(output)
|
186
|
-
output.should include("2,
|
186
|
+
output.should include("2, Media#show")
|
187
187
|
end
|
188
188
|
|
189
189
|
end
|
@@ -9,77 +9,77 @@ module Oink::Reports
|
|
9
9
|
|
10
10
|
it "should report actions which exceed the threshold once" do
|
11
11
|
str = <<-STR
|
12
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
12
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
13
13
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
14
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
15
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
14
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
15
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
16
16
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
17
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
17
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
18
18
|
STR
|
19
19
|
|
20
20
|
io = StringIO.new(str)
|
21
21
|
output = PsuedoOutput.new
|
22
22
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
23
|
-
output.should include("1,
|
23
|
+
output.should include("1, Media#show")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not report actions which do not exceed the threshold" do
|
27
27
|
threshold = 10
|
28
28
|
|
29
29
|
str = <<-STR
|
30
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
30
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
31
31
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
32
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
33
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
32
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
33
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
34
34
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS} | PID: 4413
|
35
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
35
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
36
36
|
STR
|
37
37
|
|
38
38
|
io = StringIO.new(str)
|
39
39
|
output = PsuedoOutput.new
|
40
40
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
41
|
-
output.should_not include("1,
|
41
|
+
output.should_not include("1, Media#show")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should report actions which exceed the threshold multiple times" do
|
45
45
|
str = <<-STR
|
46
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
46
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
47
47
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
48
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
49
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
48
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
49
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
50
50
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
51
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
52
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
51
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
52
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
53
53
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
54
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
54
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
55
55
|
STR
|
56
56
|
|
57
57
|
io = StringIO.new(str)
|
58
58
|
output = PsuedoOutput.new
|
59
59
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
60
|
-
output.should include("2,
|
60
|
+
output.should include("2, Media#show")
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should order actions by most exceeded" do
|
64
64
|
str = <<-STR
|
65
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
65
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
66
66
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
67
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
68
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
67
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
68
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
69
69
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
70
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
71
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
70
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
71
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
72
72
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
73
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
74
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
73
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
74
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
75
75
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 3) + 3} | PID: 4413
|
76
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
76
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
77
77
|
STR
|
78
78
|
|
79
79
|
io = StringIO.new(str)
|
80
80
|
output = PsuedoOutput.new
|
81
81
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
82
|
-
output[-2].should == "2,
|
82
|
+
output[-2].should == "2, Media#show"
|
83
83
|
output[-1].should == "1, Users#show"
|
84
84
|
end
|
85
85
|
|
@@ -87,100 +87,100 @@ module Oink::Reports
|
|
87
87
|
threshold = 10
|
88
88
|
|
89
89
|
str = <<-STR
|
90
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
90
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
91
91
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
92
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
93
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
92
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
93
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
94
94
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
95
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
95
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
96
96
|
STR
|
97
97
|
|
98
98
|
io = StringIO.new(str)
|
99
99
|
output = PsuedoOutput.new
|
100
100
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
101
|
-
output.should_not include("1,
|
101
|
+
output.should_not include("1, Media#show")
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should not report actions from different pids" do
|
105
105
|
str = <<-STR
|
106
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
106
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
107
107
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
108
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
109
|
-
Feb 01 01:58:29 ey04-s00297 rails[5513]:
|
108
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
109
|
+
Feb 01 01:58:29 ey04-s00297 rails[5513]: Oink Action: Media#show
|
110
110
|
Feb 01 01:58:30 ey04-s00297 rails[5513]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
111
|
-
Feb 01 01:58:30 ey04-s00297 rails[5513]:
|
111
|
+
Feb 01 01:58:30 ey04-s00297 rails[5513]: Oink Log Entry Complete
|
112
112
|
STR
|
113
113
|
|
114
114
|
io = StringIO.new(str)
|
115
115
|
output = PsuedoOutput.new
|
116
116
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
117
|
-
output.should_not include("1,
|
117
|
+
output.should_not include("1, Media#show")
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "summary with top 10 offenses" do
|
121
121
|
|
122
122
|
it "should only report requests over threshold" do
|
123
123
|
str = <<-STR
|
124
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
124
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
125
125
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
126
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
127
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
126
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
127
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
128
128
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
129
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
129
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
130
130
|
STR
|
131
131
|
|
132
132
|
io = StringIO.new(str)
|
133
133
|
output = PsuedoOutput.new
|
134
134
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
135
|
-
output.should include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB,
|
135
|
+
output.should include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, Media#show")
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should not include requests which are not over the threshold" do
|
139
139
|
str = <<-STR
|
140
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
140
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
141
141
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
142
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
143
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
142
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
143
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
144
144
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS} | PID: 4413
|
145
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
145
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
146
146
|
STR
|
147
147
|
|
148
148
|
io = StringIO.new(str)
|
149
149
|
output = PsuedoOutput.new
|
150
150
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
151
|
-
output.should_not include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB,
|
151
|
+
output.should_not include("1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, Media#show")
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should order offenses from biggest to smallest" do
|
155
155
|
str = <<-STR
|
156
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
156
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
157
157
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
158
|
-
Feb 01 01:58:31 ey04-s00297 rails[4413]:
|
159
|
-
Feb 01 01:58:32 ey04-s00297 rails[4413]:
|
158
|
+
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
159
|
+
Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
|
160
160
|
Feb 01 01:58:33 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
161
|
-
Feb 01 01:58:34 ey04-s00297 rails[4413]:
|
162
|
-
Feb 01 01:58:35 ey04-s00297 rails[4413]:
|
161
|
+
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
162
|
+
Feb 01 01:58:35 ey04-s00297 rails[4413]: Oink Action: Details#show
|
163
163
|
Feb 01 01:58:36 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
164
|
-
Feb 01 01:58:37 ey04-s00297 rails[4413]:
|
164
|
+
Feb 01 01:58:37 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
165
165
|
STR
|
166
166
|
|
167
167
|
io = StringIO.new(str)
|
168
168
|
output = PsuedoOutput.new
|
169
169
|
MemoryUsageReport.new(io, TEN_MEGS).print(output)
|
170
|
-
output[4].should == "1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB,
|
171
|
-
output[5].should == "2. Feb 01 01:58:37, #{TEN_MEGS + 1} KB,
|
170
|
+
output[4].should == "1. Feb 01 01:58:34, #{TEN_MEGS + 1} KB, Media#show"
|
171
|
+
output[5].should == "2. Feb 01 01:58:37, #{TEN_MEGS + 1} KB, Details#show"
|
172
172
|
end
|
173
173
|
|
174
174
|
end
|
175
175
|
|
176
176
|
# it "should report the time span" do
|
177
177
|
# str = <<-STR
|
178
|
-
# Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
178
|
+
# Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
179
179
|
# Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
180
|
-
# Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
181
|
-
# Mar 13 01:58:29 ey04-s00297 rails[5513]:
|
180
|
+
# Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
181
|
+
# Mar 13 01:58:29 ey04-s00297 rails[5513]: Oink Action: Media#show
|
182
182
|
# Mar 13 01:58:30 ey04-s00297 rails[5513]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
183
|
-
# Mar 13 03:58:30 ey04-s00297 rails[5513]:
|
183
|
+
# Mar 13 03:58:30 ey04-s00297 rails[5513]: Oink Log Entry Complete
|
184
184
|
# STR
|
185
185
|
#
|
186
186
|
# io = StringIO.new(str)
|
@@ -196,14 +196,14 @@ module Oink::Reports
|
|
196
196
|
describe "verbose format" do
|
197
197
|
it "should print the full lines of actions exceeding the threshold" do
|
198
198
|
str = <<-STR
|
199
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
199
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
200
200
|
Feb 01 01:58:29 ey04-s00297 rails[4413]: Parameters: {"id"=>"2332", "controller"=>"users"}
|
201
201
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
202
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
203
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
202
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
203
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
204
204
|
Feb 01 01:58:29 ey04-s00297 rails[4413]: Parameters: {"id"=>"22900", "controller"=>"media"}
|
205
205
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
206
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
206
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
207
207
|
STR
|
208
208
|
io = StringIO.new(str)
|
209
209
|
output = PsuedoOutput.new
|
@@ -215,15 +215,15 @@ module Oink::Reports
|
|
215
215
|
threshold = 10
|
216
216
|
|
217
217
|
str = <<-STR
|
218
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
218
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
219
219
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
220
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
221
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
220
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
221
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
222
222
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
223
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
223
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
224
224
|
Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing ActorController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
|
225
225
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{(TEN_MEGS * 2) + 2} | PID: 4413
|
226
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
226
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
227
227
|
STR
|
228
228
|
|
229
229
|
io = StringIO.new(str)
|
@@ -237,28 +237,28 @@ module Oink::Reports
|
|
237
237
|
it "should accept multiple files" do
|
238
238
|
|
239
239
|
str1 = <<-STR
|
240
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
240
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
241
241
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
242
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
243
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
242
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
243
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
244
244
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
245
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
245
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
246
246
|
STR
|
247
247
|
|
248
248
|
str2 = <<-STR
|
249
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
249
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
|
250
250
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: 0 | PID: 4413
|
251
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
252
|
-
Feb 01 01:58:29 ey04-s00297 rails[4413]:
|
251
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
252
|
+
Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
|
253
253
|
Feb 01 01:58:30 ey04-s00297 rails[4413]: Memory usage: #{TEN_MEGS + 1} | PID: 4413
|
254
|
-
Feb 01 01:58:30 ey04-s00297 rails[4413]:
|
254
|
+
Feb 01 01:58:30 ey04-s00297 rails[4413]: Oink Log Entry Complete
|
255
255
|
STR
|
256
256
|
|
257
257
|
io1 = StringIO.new(str1)
|
258
258
|
io2 = StringIO.new(str2)
|
259
259
|
output = PsuedoOutput.new
|
260
260
|
MemoryUsageReport.new([io1, io2], TEN_MEGS).print(output)
|
261
|
-
output.should include("2,
|
261
|
+
output.should include("2, Media#show")
|
262
262
|
end
|
263
263
|
|
264
264
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 2
|
10
|
+
version: 0.9.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Noah Davis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-05 00:00:00 -04:00
|
19
19
|
default_executable: oink
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -130,20 +130,6 @@ dependencies:
|
|
130
130
|
requirement: *id008
|
131
131
|
prerelease: false
|
132
132
|
name: ruby-debug
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
type: :runtime
|
135
|
-
version_requirements: &id009 !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
version: "0"
|
144
|
-
requirement: *id009
|
145
|
-
prerelease: false
|
146
|
-
name: hodel_3000_compliant_logger
|
147
133
|
description: Log parser to identify actions which significantly increase VM heap size
|
148
134
|
email: noahd1@yahoo.com
|
149
135
|
executables:
|
@@ -180,6 +166,7 @@ files:
|
|
180
166
|
- spec/helpers/database.rb
|
181
167
|
- spec/oink/instrumentation/instance_type_counter_spec.rb
|
182
168
|
- spec/oink/instrumentation/memory_snapshot_spec.rb
|
169
|
+
- spec/oink/middleware_configuration_spec.rb
|
183
170
|
- spec/oink/middleware_spec.rb
|
184
171
|
- spec/oink/rails/instance_type_counter_spec.rb
|
185
172
|
- spec/oink/rails/memory_usage_logger_spec.rb
|
@@ -228,6 +215,7 @@ test_files:
|
|
228
215
|
- spec/helpers/database.rb
|
229
216
|
- spec/oink/instrumentation/instance_type_counter_spec.rb
|
230
217
|
- spec/oink/instrumentation/memory_snapshot_spec.rb
|
218
|
+
- spec/oink/middleware_configuration_spec.rb
|
231
219
|
- spec/oink/middleware_spec.rb
|
232
220
|
- spec/oink/rails/instance_type_counter_spec.rb
|
233
221
|
- spec/oink/rails/memory_usage_logger_spec.rb
|