request-log-analyzer 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/request_log_analyzer.rb +1 -1
- data/lib/request_log_analyzer/file_format/apache.rb +31 -3
- data/request-log-analyzer.gemspec +2 -2
- data/spec/fixtures/{apache.log → apache_combined.log} +0 -0
- data/spec/fixtures/apache_common.log +10 -0
- data/spec/integration/command_line_usage_spec.rb +3 -3
- data/spec/unit/file_format/apache_format_spec.rb +90 -12
- metadata +3 -2
data/lib/request_log_analyzer.rb
CHANGED
@@ -11,7 +11,7 @@ module RequestLogAnalyzer
|
|
11
11
|
|
12
12
|
# The current version of request-log-analyzer.
|
13
13
|
# This will be diplayed in output reports etc.
|
14
|
-
VERSION = "1.2.
|
14
|
+
VERSION = "1.2.9"
|
15
15
|
|
16
16
|
# Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
|
17
17
|
# <tt>const</tt>:: The constant that is not yet loaded in the RequestLogAnalyzer namespace. This should be passed as a string or symbol.
|
@@ -16,11 +16,20 @@ module RequestLogAnalyzer::FileFormat
|
|
16
16
|
|
17
17
|
# A hash that defines how the log format directives should be parsed.
|
18
18
|
LOG_DIRECTIVES = {
|
19
|
-
'h' => { :regexp => '(
|
19
|
+
'h' => { :regexp => '([A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+)', :captures => [{:name => :remote_host, :type => :string}] },
|
20
|
+
'a' => { :regexp => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', :captures => [{:name => :remote_ip, :type => :string}] },
|
21
|
+
'b' => { :regexp => '(\d+|-)', :captures => [{:name => :bytes_sent, :type => :integer}] },
|
22
|
+
'c' => { :regexp => '(\+|\-|\X)', :captures => [{:name => :connection_status, :type => :integer}] },
|
23
|
+
'l' => { :regexp => '([\w-]+)', :captures => [{:name => :remote_logname, :type => :nillable_string}] },
|
24
|
+
'T' => { :regexp => '((?:\d+(?:\.\d+)?)|-)', :captures => [{:name => :duration, :type => :duration, :unit => :sec}] },
|
20
25
|
't' => { :regexp => '\[([^\]]{26})\]', :captures => [{:name => :timestamp, :type => :timestamp}] },
|
21
26
|
's' => { :regexp => '(\d{3})', :captures => [{:name => :http_status, :type => :integer}] },
|
27
|
+
'u' => { :regexp => '(\w+|-)', :captures => [{:name => :user, :type => :nillable_string}] },
|
22
28
|
'r' => { :regexp => '([A-Z]+) ([^\s]+) HTTP\/(\d+(?:\.\d+)*)', :captures => [{:name => :http_method, :type => :string},
|
23
|
-
{:name => :path, :type => :string}, {:name => :http_version, :type => :string}]}
|
29
|
+
{:name => :path, :type => :string}, {:name => :http_version, :type => :string}]},
|
30
|
+
'i' => { 'Referer' => { :regexp => '([^\s]+)', :captures => [{:name => :referer, :type => :nillable_string}] },
|
31
|
+
'User-agent' => { :regexp => '(.*)', :captures => [{:name => :user_agent, :type => :user_agent}] }
|
32
|
+
}
|
24
33
|
}
|
25
34
|
|
26
35
|
# Creates the Apache log format language based on a Apache log format string.
|
@@ -41,9 +50,13 @@ module RequestLogAnalyzer::FileFormat
|
|
41
50
|
format_string.scan(/([^%]*)(?:%(?:\{([^\}]+)\})?>?([A-Za-z]))?/) do |literal, arg, variable|
|
42
51
|
|
43
52
|
line_regexp << Regexp.quote(literal) # Make sure to parse the literal before the directive
|
53
|
+
|
44
54
|
if variable
|
45
55
|
# Check if we recognize the log directive
|
46
|
-
|
56
|
+
directive = LOG_DIRECTIVES[variable]
|
57
|
+
directive = directive[arg] if directive && arg
|
58
|
+
|
59
|
+
if directive
|
47
60
|
line_regexp << directive[:regexp] # Parse the value of the directive
|
48
61
|
captures += directive[:captures] # Add the directive's information to the captures
|
49
62
|
else
|
@@ -68,6 +81,13 @@ module RequestLogAnalyzer::FileFormat
|
|
68
81
|
analyze.frequency :category => :http_status, :amount => 20, :title => "HTTP statuses" if line_definition.captures?(:http_status)
|
69
82
|
analyze.frequency :category => :path, :amount => 20, :title => "Most popular URIs" if line_definition.captures?(:path)
|
70
83
|
|
84
|
+
analyze.frequency :category => :user_agent, :amount => 20, :title => "User agents" if line_definition.captures?(:user_agent)
|
85
|
+
analyze.frequency :category => :referer, :amount => 20, :title => "Referers" if line_definition.captures?(:referer)
|
86
|
+
|
87
|
+
if line_definition.captures?(:path) && line_definition.captures?(:duration)
|
88
|
+
analyze.duration :duration => :duration, :category => :path , :title => 'Request duration'
|
89
|
+
end
|
90
|
+
|
71
91
|
return analyze.trackers
|
72
92
|
end
|
73
93
|
|
@@ -82,6 +102,14 @@ module RequestLogAnalyzer::FileFormat
|
|
82
102
|
d = /^(\d{2})\/(\w{3})\/(\d{4}):(\d{2}):(\d{2}):(\d{2})/.match(value).captures
|
83
103
|
"#{d[2]}#{MONTHS[d[1]]}#{d[0]}#{d[3]}#{d[4]}#{d[5]}".to_i
|
84
104
|
end
|
105
|
+
|
106
|
+
def convert_user_agent(value, definition)
|
107
|
+
value # TODO
|
108
|
+
end
|
109
|
+
|
110
|
+
def convert_nillable_string(value, definition)
|
111
|
+
value == '-' ? nil : value
|
112
|
+
end
|
85
113
|
end
|
86
114
|
end
|
87
115
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'request-log-analyzer'
|
3
|
-
s.version = "1.2.
|
3
|
+
s.version = "1.2.9"
|
4
4
|
s.date = "2009-09-08"
|
5
5
|
|
6
6
|
s.rubyforge_project = 'r-l-a'
|
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.email = ['willem@railsdoctors.com', 'bart@railsdoctors.com']
|
32
32
|
s.homepage = 'http://railsdoctors.com'
|
33
33
|
|
34
|
-
s.files = %w(spec/unit/filter/anonymize_filter_spec.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/fixtures/rails_22_cached.log lib/request_log_analyzer/file_format/rails_development.rb spec/lib/macros.rb spec/fixtures/merb_prefixed.log tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/fixtures/decompression.log.bz2 lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb spec/fixtures/rails_unordered.log bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/matchers.rb spec/fixtures/test_order.log lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb spec/lib/testing_format.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/aggregator.rb lib/cli/progressbar.rb README.rdoc spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb Rakefile spec/unit/filter/filter_spec.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/test_language_combined.log spec/fixtures/decompression.tar.gz spec/unit/filter/field_filter_spec.rb spec/spec.opts lib/request_log_analyzer/aggregator/database.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/
|
34
|
+
s.files = %w(spec/unit/filter/anonymize_filter_spec.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/fixtures/rails_22_cached.log lib/request_log_analyzer/file_format/rails_development.rb spec/lib/macros.rb spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/merb_prefixed.log tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/fixtures/decompression.log.bz2 lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb spec/fixtures/rails_unordered.log bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/matchers.rb spec/fixtures/test_order.log lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb spec/lib/testing_format.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/aggregator.rb lib/cli/progressbar.rb README.rdoc spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb Rakefile spec/unit/filter/filter_spec.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/test_language_combined.log spec/fixtures/decompression.tar.gz spec/unit/filter/field_filter_spec.rb spec/spec.opts lib/request_log_analyzer/aggregator/database.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/header_and_footer.log lib/cli/tools.rb lib/request_log_analyzer/file_format/merb.rb spec/fixtures/multiple_files_1.log spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/request.rb spec/unit/controller/controller_spec.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/file_format/apache.rb spec/lib/helpers.rb spec/fixtures/rails_1x.log spec/lib/mocks.rb spec/fixtures/decompression.log.zip spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/aggregator/database_spec.rb spec/fixtures/test_file_format.log lib/request_log_analyzer/source/database.rb tasks/github-gem.rake lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/file_format.rb spec/unit/aggregator/summarizer_spec.rb spec/fixtures/rails_22.log spec/fixtures/multiple_files_2.log spec/fixtures/syslog_1x.log LICENSE spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb lib/cli/command_line_arguments.rb)
|
35
35
|
s.test_files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/controller/controller_spec.rb spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/aggregator/database_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb)
|
36
36
|
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
1.56.136.157 - - [08/Sep/2009:07:54:07 -0400] "GET /form_configurations/show.flashxml HTTP/1.1" 304 -
|
2
|
+
1.72.56.31 - - [08/Sep/2009:07:54:07 -0400] "GET /users/M17286/projects.xml?per_page=8000 HTTP/1.1" 404 1
|
3
|
+
1.82.235.29 - - [08/Sep/2009:07:54:05 -0400] "GET /gallery/fresh?page=23&per_page=16 HTTP/1.1" 200 23414
|
4
|
+
1.56.136.157 - - [08/Sep/2009:07:54:08 -0400] "GET /designs/20110457.flashxml HTTP/1.1" 304 -
|
5
|
+
1.56.136.157 - - [08/Sep/2009:07:54:08 -0400] "GET /object_libraries/1.flashxml HTTP/1.1" 304 -
|
6
|
+
1.249.68.72 - - [08/Sep/2009:07:54:09 -0400] "GET /projects/18182835-my-first-project HTTP/1.1" 200 10435
|
7
|
+
1.108.106.20 - - [08/Sep/2009:07:54:09 -0400] "GET /login HTTP/1.1" 200 9522
|
8
|
+
1.129.119.13 - - [08/Sep/2009:07:54:09 -0400] "GET /profile/18543424 HTTP/1.0" 200 8223
|
9
|
+
1.158.151.25 - - [08/Sep/2009:07:54:09 -0400] "GET /projects/18236114-home/floors/18252888-/designs/19406560-home-1 HTTP/1.1" 200 10434
|
10
|
+
1.29.137.1 - - [08/Sep/2009:07:54:10 -0400] "GET /assets/custom/blah/images/print_logo.jpg HTTP/1.1" 200 10604
|
@@ -55,13 +55,13 @@ describe RequestLogAnalyzer, 'running from command line' do
|
|
55
55
|
output.all? { |line| /^[\x00-\x7F]*$/ =~ line }.should be_true
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should parse a Merb file if --
|
58
|
+
it "should parse a Merb file if --format merb is set" do
|
59
59
|
output = run("#{log_fixture(:merb)} --format merb")
|
60
60
|
output.detect { |line| /Parsed requests\:\s*11/ =~ line }.should_not be_nil
|
61
61
|
end
|
62
62
|
|
63
|
-
it "should parse a Apache access log file if --format
|
64
|
-
output = run("#{log_fixture(:
|
63
|
+
it "should parse a Apache access log file if --apache-format is set" do
|
64
|
+
output = run("#{log_fixture(:apache_combined)} --apache-format combined")
|
65
65
|
output.detect { |line| /Parsed requests\:\s*5/ =~ line }.should_not be_nil
|
66
66
|
end
|
67
67
|
|
@@ -4,7 +4,7 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
4
4
|
|
5
5
|
describe '.access_line_definition' do
|
6
6
|
before(:each) do
|
7
|
-
@format_string = '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"'
|
7
|
+
@format_string = '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i" %T'
|
8
8
|
@line_definition = RequestLogAnalyzer::FileFormat::Apache.access_line_definition(@format_string)
|
9
9
|
end
|
10
10
|
|
@@ -13,7 +13,7 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should create a list of captures for the values in the lines" do
|
16
|
-
@line_definition.captures.should
|
16
|
+
@line_definition.captures.should have(12).items
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should make it a header line" do
|
@@ -23,6 +23,10 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
23
23
|
it "should make it a footer line" do
|
24
24
|
@line_definition.should be_footer
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should capture :duration" do
|
28
|
+
@line_definition.captures?(:duration).should be_true
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
describe '.create' do
|
@@ -33,7 +37,7 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
33
37
|
end
|
34
38
|
|
35
39
|
it "should create the :access line definition" do
|
36
|
-
@format.should have_line_definition(:access).capturing(:timestamp, :
|
40
|
+
@format.should have_line_definition(:access).capturing(:timestamp, :remote_host, :bytes_sent, :http_method, :path, :http_version, :http_status)
|
37
41
|
end
|
38
42
|
|
39
43
|
it "should be a valid file format" do
|
@@ -45,12 +49,64 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
|
-
context 'log parsing' do
|
52
|
+
context '"Common" access log parsing' do
|
53
|
+
before(:all) do
|
54
|
+
@file_format = RequestLogAnalyzer::FileFormat.load(:apache, :common)
|
55
|
+
@log_parser = RequestLogAnalyzer::Source::LogParser.new(@file_format)
|
56
|
+
@sample_1 = '1.129.119.13 - - [08/Sep/2009:07:54:09 -0400] "GET /profile/18543424 HTTP/1.0" 200 8223'
|
57
|
+
@sample_2 = '1.82.235.29 - - [08/Sep/2009:07:54:05 -0400] "GET /gallery/fresh?page=23&per_page=16 HTTP/1.1" 200 23414'
|
58
|
+
end
|
49
59
|
|
50
|
-
|
51
|
-
@file_format
|
60
|
+
it "should have a valid language definitions" do
|
61
|
+
@file_format.should be_valid
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse a valid access log line" do
|
65
|
+
@file_format.line_definitions[:access].matches(@sample_1).should be_kind_of(Hash)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not parse a valid access log line" do
|
69
|
+
@file_format.line_definitions[:access].matches('addasdsasadadssadasd').should be_false
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should read the correct values from a valid HTTP/1.0 access log line" do
|
73
|
+
@log_parser.parse_io(@sample_1) do |request|
|
74
|
+
request[:remote_host].should == '1.129.119.13'
|
75
|
+
request[:timestamp].should == 20090908075409
|
76
|
+
request[:http_status].should == 200
|
77
|
+
request[:http_method].should == 'GET'
|
78
|
+
request[:http_version].should == '1.0'
|
79
|
+
request[:bytes_sent].should == 8223
|
80
|
+
request[:user].should == nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should read the correct values from a valid 200 access log line" do
|
85
|
+
@log_parser.parse_io(@sample_2) do |request|
|
86
|
+
request[:remote_host].should == '1.82.235.29'
|
87
|
+
request[:timestamp].should == 20090908075405
|
88
|
+
request[:http_status].should == 200
|
89
|
+
request[:http_method].should == 'GET'
|
90
|
+
request[:http_version].should == '1.1'
|
91
|
+
request[:bytes_sent].should == 23414
|
92
|
+
request[:user].should == nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should parse 10 request from fixture access log" do
|
97
|
+
counter = mock('counter')
|
98
|
+
counter.should_receive(:hit!).exactly(10).times
|
99
|
+
@log_parser.parse_file(log_fixture(:apache_common)) { counter.hit! }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context '"Combined" access log parsing' do
|
104
|
+
|
105
|
+
before(:all) do
|
106
|
+
@file_format = RequestLogAnalyzer::FileFormat.load(:apache, :combined)
|
52
107
|
@log_parser = RequestLogAnalyzer::Source::LogParser.new(@file_format)
|
53
|
-
@
|
108
|
+
@sample_1 = '69.41.0.45 - - [02/Sep/2009:12:02:40 +0200] "GET //phpMyAdmin/ HTTP/1.1" 404 209 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"'
|
109
|
+
@sample_2 = '10.0.1.1 - - [02/Sep/2009:05:08:33 +0200] "GET / HTTP/1.1" 200 30 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"'
|
54
110
|
end
|
55
111
|
|
56
112
|
it "should have a valid language definitions" do
|
@@ -58,23 +114,45 @@ describe RequestLogAnalyzer::FileFormat::Apache do
|
|
58
114
|
end
|
59
115
|
|
60
116
|
it "should parse a valid access log line" do
|
61
|
-
@file_format.line_definitions[:access].matches(@
|
117
|
+
@file_format.line_definitions[:access].matches(@sample_1).should be_kind_of(Hash)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should not parse a valid access log line" do
|
121
|
+
@file_format.line_definitions[:access].matches('addasdsasadadssadasd').should be_false
|
62
122
|
end
|
63
123
|
|
64
|
-
it "should read the correct values from a valid access log line" do
|
65
|
-
@log_parser.parse_io(@
|
66
|
-
request[:
|
124
|
+
it "should read the correct values from a valid 404 access log line" do
|
125
|
+
@log_parser.parse_io(@sample_1) do |request|
|
126
|
+
request[:remote_host].should == '69.41.0.45'
|
67
127
|
request[:timestamp].should == 20090902120240
|
68
128
|
request[:http_status].should == 404
|
69
129
|
request[:http_method].should == 'GET'
|
70
130
|
request[:http_version].should == '1.1'
|
131
|
+
request[:bytes_sent].should == 209
|
132
|
+
request[:referer].should == nil
|
133
|
+
request[:user].should == nil
|
134
|
+
request[:user_agent].should == 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)'
|
71
135
|
end
|
72
136
|
end
|
137
|
+
|
138
|
+
it "should read the correct values from a valid 200 access log line" do
|
139
|
+
@log_parser.parse_io(@sample_2) do |request|
|
140
|
+
request[:remote_host].should == '10.0.1.1'
|
141
|
+
request[:timestamp].should == 20090902050833
|
142
|
+
request[:http_status].should == 200
|
143
|
+
request[:http_method].should == 'GET'
|
144
|
+
request[:http_version].should == '1.1'
|
145
|
+
request[:bytes_sent].should == 30
|
146
|
+
request[:referer].should == nil
|
147
|
+
request[:user].should == nil
|
148
|
+
request[:user_agent].should == 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9'
|
149
|
+
end
|
150
|
+
end
|
73
151
|
|
74
152
|
it "should parse 5 request from fixture access log" do
|
75
153
|
counter = mock('counter')
|
76
154
|
counter.should_receive(:hit!).exactly(5).times
|
77
|
-
@log_parser.parse_file(log_fixture(:
|
155
|
+
@log_parser.parse_file(log_fixture(:apache_combined)) { counter.hit! }
|
78
156
|
end
|
79
157
|
end
|
80
158
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- spec/fixtures/rails_22_cached.log
|
52
52
|
- lib/request_log_analyzer/file_format/rails_development.rb
|
53
53
|
- spec/lib/macros.rb
|
54
|
+
- spec/fixtures/apache_combined.log
|
55
|
+
- spec/fixtures/apache_common.log
|
54
56
|
- spec/fixtures/merb_prefixed.log
|
55
57
|
- tasks/request_log_analyzer.rake
|
56
58
|
- spec/unit/file_format/file_format_api_spec.rb
|
@@ -101,7 +103,6 @@ files:
|
|
101
103
|
- spec/fixtures/decompression.tgz
|
102
104
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
103
105
|
- spec/unit/tracker/hourly_spread_spec.rb
|
104
|
-
- spec/fixtures/apache.log
|
105
106
|
- spec/fixtures/header_and_footer.log
|
106
107
|
- lib/cli/tools.rb
|
107
108
|
- lib/request_log_analyzer/file_format/merb.rb
|