request-log-analyzer 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cli/tools.rb +19 -16
- data/lib/request_log_analyzer/file_format/amazon_s3.rb +1 -1
- data/lib/request_log_analyzer/file_format/apache.rb +5 -4
- data/lib/request_log_analyzer/file_format/merb.rb +1 -1
- data/lib/request_log_analyzer/file_format/rails.rb +1 -1
- data/lib/request_log_analyzer/file_format.rb +4 -0
- data/lib/request_log_analyzer.rb +1 -1
- data/request-log-analyzer.gemspec +11 -10
- data/spec/fixtures/sinatra.log +99 -0
- data/spec/unit/file_format/format_autodetection_spec.rb +8 -3
- data/spec/unit/file_format/rack_format_spec.rb +50 -0
- data/spec/unit/file_format/rails_format_spec.rb +5 -0
- metadata +8 -5
data/lib/cli/tools.rb
CHANGED
@@ -2,24 +2,27 @@
|
|
2
2
|
# If it is not possible to to so, it returns the default_width.
|
3
3
|
# <tt>default_width</tt> Defaults to 81
|
4
4
|
def terminal_width(default_width = 81)
|
5
|
-
|
6
|
-
data = [0, 0, 0, 0].pack("SSSS")
|
7
|
-
if @out.ioctl(tiocgwinsz, data) >= 0
|
8
|
-
rows, cols, xpixels, ypixels = data.unpack("SSSS")
|
9
|
-
raise unless cols > 0
|
10
|
-
cols
|
11
|
-
else
|
12
|
-
raise
|
13
|
-
end
|
14
|
-
rescue
|
5
|
+
|
15
6
|
begin
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
7
|
+
tiocgwinsz = 0x5413
|
8
|
+
data = [0, 0, 0, 0].pack("SSSS")
|
9
|
+
if !RUBY_PLATFORM.include?('java') && @out.ioctl(tiocgwinsz, data) >= 0 # JRuby crashes on ioctl
|
10
|
+
rows, cols, xpixels, ypixels = data.unpack("SSSS")
|
11
|
+
raise unless cols > 0
|
12
|
+
cols
|
13
|
+
else
|
14
|
+
raise
|
15
|
+
end
|
16
|
+
rescue
|
17
|
+
begin
|
18
|
+
IO.popen('stty -a 2>&1') do |pipe|
|
19
|
+
column_line = pipe.detect { |line| /(\d+) columns/ =~ line }
|
20
|
+
raise unless column_line
|
21
|
+
$1.to_i
|
22
|
+
end
|
23
|
+
rescue
|
24
|
+
default_width
|
20
25
|
end
|
21
|
-
rescue
|
22
|
-
default_width
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -9,7 +9,7 @@ module RequestLogAnalyzer::FileFormat
|
|
9
9
|
line_definition :access do |line|
|
10
10
|
line.header = true
|
11
11
|
line.footer = true
|
12
|
-
line.regexp = /^([^\ ]+) ([^\ ]+) \[(\d{2}\/[A-Za-z]{3}\/\d{4}.\d{2}:\d{2}:\d{2})(?: .\d{4})?\] (\d
|
12
|
+
line.regexp = /^([^\ ]+) ([^\ ]+) \[(\d{2}\/[A-Za-z]{3}\/\d{4}.\d{2}:\d{2}:\d{2})(?: .\d{4})?\] ([\d\.:]+) ([^\ ]+) ([^\ ]+) (\w+(?:\.\w+)*) ([^\ ]+) "([^"]+)" (\d+) ([^\ ]+) (\d+) (\d+) (\d+) (\d+) "([^"]+)" "([^"]+)"/
|
13
13
|
line.captures << { :name => :bucket_owner, :type => :string } <<
|
14
14
|
{ :name => :bucket, :type => :string } <<
|
15
15
|
{ :name => :timestamp, :type => :timestamp } <<
|
@@ -27,7 +27,7 @@ module RequestLogAnalyzer::FileFormat
|
|
27
27
|
LOG_DIRECTIVES = {
|
28
28
|
'%' => { :regexp => '%', :captures => [] },
|
29
29
|
'h' => { :regexp => '([A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+)', :captures => [{:name => :remote_host, :type => :string}] },
|
30
|
-
'a' => { :regexp => '(\d
|
30
|
+
'a' => { :regexp => '([\d\.:]+)', :captures => [{:name => :remote_ip, :type => :string}] },
|
31
31
|
'b' => { :regexp => '(\d+|-)', :captures => [{:name => :bytes_sent, :type => :traffic}] },
|
32
32
|
'c' => { :regexp => '(\+|\-|\X)', :captures => [{:name => :connection_status, :type => :integer}] },
|
33
33
|
'D' => { :regexp => '(\d+|-)', :captures => [{:name => :duration, :type => :duration, :unit => :musec}] },
|
@@ -57,11 +57,12 @@ module RequestLogAnalyzer::FileFormat
|
|
57
57
|
def self.access_line_definition(format_string)
|
58
58
|
format_string ||= :common
|
59
59
|
format_string = LOG_FORMAT_DEFAULTS[format_string.to_sym] || format_string
|
60
|
-
|
60
|
+
|
61
|
+
|
61
62
|
line_regexp = ''
|
62
63
|
captures = []
|
63
64
|
format_string.scan(/([^%]*)(?:%(?:\{([^\}]+)\})?>?([A-Za-z%]))?/) do |literal, arg, variable|
|
64
|
-
|
65
|
+
|
65
66
|
line_regexp << Regexp.quote(literal) # Make sure to parse the literal before the directive
|
66
67
|
|
67
68
|
if variable
|
@@ -78,7 +79,7 @@ module RequestLogAnalyzer::FileFormat
|
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
81
|
-
|
82
|
+
|
82
83
|
# Return a new line definition object
|
83
84
|
return RequestLogAnalyzer::LineDefinition.new(:access, :regexp => Regexp.new(line_regexp),
|
84
85
|
:captures => captures, :header => true, :footer => true)
|
@@ -14,7 +14,7 @@ module RequestLogAnalyzer::FileFormat
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# ~ Params: {"action"=>"create", "controller"=>"session"}
|
17
|
-
# ~ Params: {"_method"=>"delete", "authenticity_token"=>"[FILTERED]", "action"=>"
|
17
|
+
# ~ Params: {"_method"=>"delete", "authenticity_token"=>"[FILTERED]", "action"=>"destroy"}
|
18
18
|
line_definition :params do |line|
|
19
19
|
line.teaser = /Params\:\ /
|
20
20
|
line.regexp = /Params\:\ (\{.+\})/
|
@@ -86,7 +86,7 @@ module RequestLogAnalyzer::FileFormat
|
|
86
86
|
LINE_DEFINITIONS = {
|
87
87
|
:processing => RequestLogAnalyzer::LineDefinition.new(:processing, :header => true,
|
88
88
|
:teaser => /Processing /,
|
89
|
-
:regexp => /Processing ((?:\w+::)?\w+)#(\w+)(?: to (\w+))? \(for (\d
|
89
|
+
:regexp => /Processing ((?:\w+::)?\w+)#(\w+)(?: to (\w+))? \(for ([\d\.:]+) at (\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)\) \[([A-Z]+)\]/,
|
90
90
|
:captures => [{ :name => :controller, :type => :string },
|
91
91
|
{ :name => :action, :type => :string },
|
92
92
|
{ :name => :format, :type => :string, :default => 'html' },
|
@@ -85,6 +85,10 @@ module RequestLogAnalyzer::FileFormat
|
|
85
85
|
score -= parser.warnings * 3
|
86
86
|
score += parser.parsed_lines * 1
|
87
87
|
score += parser.parsed_requests * 10
|
88
|
+
|
89
|
+
# As Apache matches several simular formats, subtracting 1 will make a specific matcher have a higher score
|
90
|
+
score -= 1 if parser.file_format.class == RequestLogAnalyzer::FileFormat::Apache
|
91
|
+
|
88
92
|
score
|
89
93
|
end
|
90
94
|
|
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
|
# Do not change the value by hand; it will be updated automatically by the gem release script.
|
14
|
-
VERSION = "1.5.
|
14
|
+
VERSION = "1.5.2"
|
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.
|
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = "request-log-analyzer"
|
3
3
|
|
4
4
|
# Do not set the version and date field manually, this is done by the release script
|
5
|
-
s.version = "1.5.
|
6
|
-
s.date = "2009-
|
5
|
+
s.version = "1.5.2"
|
6
|
+
s.date = "2009-12-02"
|
7
7
|
|
8
8
|
s.rubyforge_project = 'r-l-a'
|
9
9
|
|
@@ -11,13 +11,14 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.executables = ['request-log-analyzer']
|
12
12
|
s.default_executable = 'request-log-analyzer'
|
13
13
|
|
14
|
-
s.summary = "A command line tool to analyze request logs for Apache, Rails, Merb and other web application servers"
|
14
|
+
s.summary = "A command line tool to analyze request logs for Apache, Rails, Merb, MySQL and other web application servers"
|
15
15
|
s.description = <<-eos
|
16
|
-
Request log analyzer's purpose is to find
|
17
|
-
This tool will parse all requests in the application's log file and aggregate the
|
18
|
-
the log file(s), it will show the requests that take op most server time
|
19
|
-
parsed request information into a database so you can roll your own
|
20
|
-
|
16
|
+
Request log analyzer's purpose is to find out how your web application is being used, how it performs and to
|
17
|
+
focus your optimization efforts. This tool will parse all requests in the application's log file and aggregate the
|
18
|
+
information. Once it is finished parsing the log file(s), it will show the requests that take op most server time
|
19
|
+
using various metrics. It can also insert all parsed request information into a database so you can roll your own
|
20
|
+
analysis. It supports Rails-, Merb- and Rack-based applications logs, Apache and Amazon S3 access logs and MySQL
|
21
|
+
slow query logs out of the box, but file formats of other applications can easily be supported by supplying an
|
21
22
|
easy to write log file format definition.
|
22
23
|
eos
|
23
24
|
|
@@ -35,6 +36,6 @@ Gem::Specification.new do |s|
|
|
35
36
|
|
36
37
|
# The files and test_files directives are set automatically by the release script.
|
37
38
|
# Do not change them by hand, but make sure to add the files to the git repository.
|
38
|
-
s.files = %w(
|
39
|
-
s.test_files = %w(spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/database/base_class_spec.rb spec/unit/filter/filter_spec.rb spec/unit/tracker/count_tracker_spec.rb spec/unit/database/connection_spec.rb spec/integration/scout_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/integration/mailer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/file_format/rails_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/request_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/mailer_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/traffic_tracker_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/controller/controller_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/database/database_spec.rb)
|
39
|
+
s.files = %w(spec/unit/tracker/hourly_spread_spec.rb lib/request_log_analyzer/output/html.rb DESIGN.rdoc spec/fixtures/rails_unordered.log spec/fixtures/multiple_files_1.log lib/request_log_analyzer/database/source.rb README.rdoc spec/unit/file_format/amazon_s3_format_spec.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/rails_22.log spec/fixtures/test_order.log spec/unit/database/base_class_spec.rb lib/request_log_analyzer/database/connection.rb lib/request_log_analyzer/aggregator.rb spec/fixtures/decompression.log lib/request_log_analyzer/file_format/apache.rb spec/unit/file_format/rack_format_spec.rb spec/fixtures/decompression.log.gz lib/request_log_analyzer/tracker/frequency.rb lib/request_log_analyzer/tracker/duration.rb tasks/github-gem.rake .gitignore spec/unit/filter/filter_spec.rb spec/lib/macros.rb spec/spec_helper.rb spec/unit/tracker/count_tracker_spec.rb spec/fixtures/decompression.log.bz2 spec/unit/database/connection_spec.rb lib/request_log_analyzer/filter.rb spec/integration/scout_spec.rb spec/fixtures/test_file_format.log lib/request_log_analyzer/tracker/traffic.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/file_format/merb.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/file_format/amazon_s3.rb lib/cli/database_console.rb spec/integration/mailer_spec.rb lib/request_log_analyzer/line_definition.rb spec/unit/tracker/frequency_tracker_spec.rb spec/fixtures/multiple_files_2.log spec/lib/mocks.rb spec/unit/file_format/apache_format_spec.rb spec/fixtures/syslog_1x.log spec/integration/munin_plugins_rails_spec.rb spec/lib/helpers.rb spec/fixtures/rails.db spec/unit/source/log_parser_spec.rb lib/request_log_analyzer/aggregator/database_inserter.rb spec/fixtures/header_and_footer.log spec/lib/testing_format.rb lib/request_log_analyzer/database.rb spec/unit/file_format/rails_format_spec.rb lib/request_log_analyzer/request.rb lib/request_log_analyzer/output/fixed_width.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/file_format/rack.rb spec/fixtures/test_language_combined.log lib/cli/command_line_arguments.rb lib/request_log_analyzer.rb spec/database.yml spec/unit/request_spec.rb lib/request_log_analyzer/database/base.rb spec/unit/aggregator/database_inserter_spec.rb lib/request_log_analyzer/database/request.rb lib/cli/database_console_init.rb lib/cli/progressbar.rb lib/request_log_analyzer/database/warning.rb spec/unit/filter/anonymize_filter_spec.rb spec/fixtures/apache_combined.log spec/fixtures/rails_22_cached.log lib/request_log_analyzer/aggregator/summarizer.rb spec/unit/tracker/duration_tracker_spec.rb spec/fixtures/rails_1x.log lib/request_log_analyzer/tracker/count.rb lib/request_log_analyzer/output.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/file_format/mysql.rb spec/unit/file_format/mysql_format_spec.rb request-log-analyzer.gemspec spec/fixtures/apache_common.log lib/request_log_analyzer/file_format/rails.rb Rakefile spec/unit/mailer_spec.rb lib/request_log_analyzer/tracker/hourly_spread.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/traffic_tracker_spec.rb lib/request_log_analyzer/tracker/timespan.rb spec/unit/controller/log_processor_spec.rb spec/fixtures/sinatra.log spec/unit/filter/field_filter_spec.rb spec/fixtures/merb_prefixed.log lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/filter/timespan.rb spec/unit/controller/controller_spec.rb lib/request_log_analyzer/mailer.rb lib/cli/tools.rb spec/fixtures/decompression.tar.gz spec/unit/tracker/timespan_tracker_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/controller.rb spec/unit/tracker/tracker_api_spec.rb lib/request_log_analyzer/source/database_loader.rb spec/fixtures/merb.log LICENSE lib/request_log_analyzer/file_format.rb tasks/request_log_analyzer.rake spec/unit/database/database_spec.rb spec/fixtures/decompression.log.zip spec/fixtures/decompression.tgz bin/request-log-analyzer lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/source.rb spec/fixtures/mysql_slow_query.log lib/request_log_analyzer/source/log_parser.rb lib/request_log_analyzer/aggregator/echo.rb)
|
40
|
+
s.test_files = %w(spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/database/base_class_spec.rb spec/unit/file_format/rack_format_spec.rb spec/unit/filter/filter_spec.rb spec/unit/tracker/count_tracker_spec.rb spec/unit/database/connection_spec.rb spec/integration/scout_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/format_autodetection_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/integration/mailer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/munin_plugins_rails_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/file_format/rails_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/request_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/filter/anonymize_filter_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/file_format/mysql_format_spec.rb spec/unit/mailer_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/traffic_tracker_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/controller/controller_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/database/database_spec.rb)
|
40
41
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Mongrel
|
2
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET / HTTP/1.1" 200 5056 0.0241
|
3
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /javascripts/cufon-yui.js HTTP/1.1" 304 - 0.0016
|
4
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /javascripts/CartoGothic_Std_400-CartoGothic_Std_700-CartoGothic_Std_italic_400-CartoGothic_Std_italic_700.font.js HTTP/1.1" 304 - 0.0013
|
5
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /css/stylesheet.css HTTP/1.1" 304 - 0.0014
|
6
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/rails_doctors_logo.png HTTP/1.1" 304 - 0.0039
|
7
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/footer-bg.png HTTP/1.1" 304 - 0.0028
|
8
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/nav-bg.png HTTP/1.1" 304 - 0.0023
|
9
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/radial-bg.png HTTP/1.1" 304 - 0.0019
|
10
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/box-bg.png HTTP/1.1" 304 - 0.0015
|
11
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/performance_train.png HTTP/1.1" 304 - 0.0011
|
12
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/lock.png HTTP/1.1" 304 - 0.0025
|
13
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/contact.png HTTP/1.1" 304 - 0.0015
|
14
|
+
127.0.0.1 - - [23/Nov/2009 22:46:22] "GET /images/rla.png HTTP/1.1" 304 - 0.0008
|
15
|
+
127.0.0.1 - - [23/Nov/2009 22:46:24] "GET /index.html HTTP/1.1" 200 5056 0.0216
|
16
|
+
127.0.0.1 - - [23/Nov/2009 22:46:25] "GET /blog.html HTTP/1.1" 200 8156 0.0115
|
17
|
+
127.0.0.1 - - [23/Nov/2009 22:46:26] "GET /performance.html HTTP/1.1" 200 4751 0.0134
|
18
|
+
127.0.0.1 - - [23/Nov/2009 22:46:26] "GET /blog.html HTTP/1.1" 200 8156 0.0504
|
19
|
+
127.0.0.1 - - [23/Nov/2009 22:46:27] "GET /security.html HTTP/1.1" 200 4503 0.0119
|
20
|
+
127.0.0.1 - - [23/Nov/2009 22:46:27] "GET /performance.html HTTP/1.1" 200 4751 0.0206
|
21
|
+
127.0.0.1 - - [23/Nov/2009 22:46:29] "GET /request_log_analyzer.html HTTP/1.1" 200 5669 0.0129
|
22
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /request_log_analyzer.html HTTP/1.1" 200 5669 0.0156
|
23
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /javascripts/cufon-yui.js HTTP/1.1" 304 - 0.0033
|
24
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /javascripts/CartoGothic_Std_400-CartoGothic_Std_700-CartoGothic_Std_italic_400-CartoGothic_Std_italic_700.font.js HTTP/1.1" 304 - 0.0035
|
25
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /css/stylesheet.css HTTP/1.1" 304 - 0.0031
|
26
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/performance_train.png HTTP/1.1" 304 - 0.0026
|
27
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/footer-bg.png HTTP/1.1" 304 - 0.0029
|
28
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/nav-bg.png HTTP/1.1" 304 - 0.0048
|
29
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/box-bg.png HTTP/1.1" 304 - 0.0055
|
30
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/rails_doctors_logo.png HTTP/1.1" 304 - 0.0049
|
31
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/radial-bg.png HTTP/1.1" 304 - 0.0029
|
32
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/lock.png HTTP/1.1" 304 - 0.0022
|
33
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/rla.png HTTP/1.1" 304 - 0.0014
|
34
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /images/contact.png HTTP/1.1" 304 - 0.0008
|
35
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /favicon.ico HTTP/1.1" 404 420 0.0007
|
36
|
+
127.0.0.1 - - [23/Nov/2009 22:46:30] "GET /contact.html HTTP/1.1" 200 4476 0.0149
|
37
|
+
127.0.0.1 - - [23/Nov/2009 22:46:31] "GET /contact.html HTTP/1.1" 200 4476 0.0118
|
38
|
+
127.0.0.1 - - [23/Nov/2009 22:46:31] "GET /contact.html HTTP/1.1" 200 4476 0.0556
|
39
|
+
127.0.0.1 - - [23/Nov/2009 22:46:32] "GET /security.html HTTP/1.1" 200 4503 0.0980
|
40
|
+
127.0.0.1 - - [23/Nov/2009 22:46:32] "GET /performance.html HTTP/1.1" 200 4751 0.0109
|
41
|
+
127.0.0.1 - - [23/Nov/2009 22:46:33] "GET /index.html HTTP/1.1" 200 5056 0.0169
|
42
|
+
127.0.0.1 - - [23/Nov/2009 22:46:33] "GET /blog.html HTTP/1.1" 200 8156 0.0112
|
43
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /blog.html HTTP/1.1" 200 8156 0.0113
|
44
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /css/stylesheet.css HTTP/1.1" 304 - 0.0017
|
45
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /javascripts/cufon-yui.js HTTP/1.1" 304 - 0.0011
|
46
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /javascripts/CartoGothic_Std_400-CartoGothic_Std_700-CartoGothic_Std_italic_400-CartoGothic_Std_italic_700.font.js HTTP/1.1" 304 - 0.0007
|
47
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/rails_doctors_logo.png HTTP/1.1" 304 - 0.0045
|
48
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/performance_train.png HTTP/1.1" 304 - 0.0038
|
49
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/footer-bg.png HTTP/1.1" 304 - 0.0044
|
50
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/nav-bg.png HTTP/1.1" 304 - 0.0042
|
51
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/radial-bg.png HTTP/1.1" 304 - 0.0037
|
52
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/box-bg.png HTTP/1.1" 304 - 0.0045
|
53
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/rla.png HTTP/1.1" 304 - 0.0026
|
54
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/lock.png HTTP/1.1" 304 - 0.0022
|
55
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /images/contact.png HTTP/1.1" 304 - 0.0024
|
56
|
+
127.0.0.1 - - [23/Nov/2009 22:46:34] "GET /favicon.ico HTTP/1.1" 404 420 0.0007
|
57
|
+
127.0.0.1 - - [23/Nov/2009 22:46:36] "GET /blog.html HTTP/1.1" 200 8156 0.0119
|
58
|
+
127.0.0.1 - - [23/Nov/2009 22:46:36] "GET /css/stylesheet.css HTTP/1.1" 200 3782 0.0030
|
59
|
+
127.0.0.1 - - [23/Nov/2009 22:46:36] "GET /javascripts/cufon-yui.js HTTP/1.1" 200 16944 0.0220
|
60
|
+
127.0.0.1 - - [23/Nov/2009 22:46:36] "GET /javascripts/CartoGothic_Std_400-CartoGothic_Std_700-CartoGothic_Std_italic_400-CartoGothic_Std_italic_700.font.js HTTP/1.1" 200 76594 0.0258
|
61
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/box-bg.png HTTP/1.1" 200 129 0.0058
|
62
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/footer-bg.png HTTP/1.1" 200 267 0.0056
|
63
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/nav-bg.png HTTP/1.1" 200 221 0.0052
|
64
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/performance_train.png HTTP/1.1" 200 7496 0.0103
|
65
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/radial-bg.png HTTP/1.1" 200 9288 0.0079
|
66
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/rails_doctors_logo.png HTTP/1.1" 200 11487 0.0106
|
67
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/rla.png HTTP/1.1" 200 23857 0.0233
|
68
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/contact.png HTTP/1.1" 200 23961 0.0228
|
69
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /images/lock.png HTTP/1.1" 200 31780 0.0494
|
70
|
+
127.0.0.1 - - [23/Nov/2009 22:46:37] "GET /favicon.ico HTTP/1.1" 404 420 0.0007
|
71
|
+
127.0.0.1 - - [23/Nov/2009 22:46:38] "GET /blog.html HTTP/1.1" 200 8156 0.0108
|
72
|
+
127.0.0.1 - - [23/Nov/2009 22:46:38] "GET /javascripts/CartoGothic_Std_400-CartoGothic_Std_700-CartoGothic_Std_italic_400-CartoGothic_Std_italic_700.font.js HTTP/1.1" 304 - 0.0017
|
73
|
+
127.0.0.1 - - [23/Nov/2009 22:46:38] "GET /javascripts/cufon-yui.js HTTP/1.1" 304 - 0.0013
|
74
|
+
127.0.0.1 - - [23/Nov/2009 22:46:38] "GET /css/stylesheet.css HTTP/1.1" 304 - 0.0024
|
75
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/rails_doctors_logo.png HTTP/1.1" 304 - 0.0073
|
76
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/performance_train.png HTTP/1.1" 304 - 0.0039
|
77
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/footer-bg.png HTTP/1.1" 304 - 0.0035
|
78
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/radial-bg.png HTTP/1.1" 304 - 0.0054
|
79
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/nav-bg.png HTTP/1.1" 304 - 0.0043
|
80
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/box-bg.png HTTP/1.1" 304 - 0.0038
|
81
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/rla.png HTTP/1.1" 304 - 0.0019
|
82
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/lock.png HTTP/1.1" 304 - 0.0014
|
83
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /images/contact.png HTTP/1.1" 304 - 0.0012
|
84
|
+
127.0.0.1 - - [23/Nov/2009 22:46:39] "GET /favicon.ico HTTP/1.1" 404 420 0.0007
|
85
|
+
127.0.0.1 - - [23/Nov/2009 22:46:40] "GET /performance.html HTTP/1.1" 200 4751 0.0110
|
86
|
+
127.0.0.1 - - [23/Nov/2009 22:46:40] "GET /performance.html HTTP/1.1" 200 4751 0.0110
|
87
|
+
127.0.0.1 - - [23/Nov/2009 22:46:41] "GET /security.html HTTP/1.1" 200 4503 0.0369
|
88
|
+
127.0.0.1 - - [23/Nov/2009 22:46:41] "GET /performance.html HTTP/1.1" 200 4751 0.0118
|
89
|
+
127.0.0.1 - - [23/Nov/2009 22:46:41] "GET /security.html HTTP/1.1" 200 4503 0.0573
|
90
|
+
127.0.0.1 - - [23/Nov/2009 22:46:42] "GET /security.html HTTP/1.1" 200 4503 0.0426
|
91
|
+
127.0.0.1 - - [23/Nov/2009 22:46:42] "GET /performance.html HTTP/1.1" 200 4751 0.0111
|
92
|
+
127.0.0.1 - - [23/Nov/2009 22:46:43] "GET /security.html HTTP/1.1" 200 4503 0.0108
|
93
|
+
127.0.0.1 - - [23/Nov/2009 22:46:43] "GET /performance.html HTTP/1.1" 200 4751 0.0105
|
94
|
+
127.0.0.1 - - [23/Nov/2009 22:46:43] "GET /security.html HTTP/1.1" 200 4503 0.0147
|
95
|
+
127.0.0.1 - - [23/Nov/2009 22:46:43] "GET /contact.html HTTP/1.1" 200 4476 0.0105
|
96
|
+
127.0.0.1 - - [23/Nov/2009 22:46:44] "GET /contact.html HTTP/1.1" 200 4476 0.0110
|
97
|
+
127.0.0.1 - - [23/Nov/2009 22:46:44] "GET /contact.html HTTP/1.1" 200 4476 0.0109
|
98
|
+
^C
|
99
|
+
== Sinatra has ended his set (crowd applauds)
|
@@ -7,12 +7,12 @@ describe RequestLogAnalyzer::FileFormat do
|
|
7
7
|
file_format = RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:merb))
|
8
8
|
file_format.should be_kind_of(RequestLogAnalyzer::FileFormat::Merb)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should autodetect a MySQL slow query log" do
|
12
12
|
file_format = RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:mysql_slow_query))
|
13
13
|
file_format.should be_kind_of(RequestLogAnalyzer::FileFormat::Mysql)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should autodetect a Rails 1.x log" do
|
17
17
|
file_format = RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:rails_1x))
|
18
18
|
file_format.should be_kind_of(RequestLogAnalyzer::FileFormat::Rails)
|
@@ -27,7 +27,12 @@ describe RequestLogAnalyzer::FileFormat do
|
|
27
27
|
file_format = RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:apache_common))
|
28
28
|
file_format.should be_kind_of(RequestLogAnalyzer::FileFormat::Apache)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
it "should autodetect a Rack access log" do
|
32
|
+
file_format = RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:sinatra))
|
33
|
+
file_format.should be_kind_of(RequestLogAnalyzer::FileFormat::Rack)
|
34
|
+
end
|
35
|
+
|
31
36
|
it "should not find any file format with a bogus file" do
|
32
37
|
RequestLogAnalyzer::FileFormat.autodetect(log_fixture(:test_order)).should be_nil
|
33
38
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe RequestLogAnalyzer::FileFormat::Rack do
|
4
|
+
|
5
|
+
context '"Sinatra" access log parsing' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@file_format = RequestLogAnalyzer::FileFormat.load(:rack)
|
9
|
+
@log_parser = RequestLogAnalyzer::Source::LogParser.new(@file_format)
|
10
|
+
@sample = '127.0.0.1 - - [23/Nov/2009 21:47:47] "GET /css/stylesheet.css HTTP/1.1" 200 3782 0.0024'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be a valid file format" do
|
14
|
+
@file_format.should be_valid
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse access lines and capture all of its fields" do
|
18
|
+
@file_format.should have_line_definition(:access).capturing(:remote_host, :timestamp, :http_method, :path, :http_version,
|
19
|
+
:http_status, :bytes_sent, :duration)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should match the sample line" do
|
23
|
+
@file_format.parse_line(@sample).should include(:line_definition, :captures)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not match a nonsense line" do
|
27
|
+
@file_format.parse_line('== Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Mongrel').should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should parse the sample fields correctly" do
|
31
|
+
match = @file_format.parse_line(@sample)
|
32
|
+
match.should_not be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should parse and convert the sample fields correctly" do
|
36
|
+
@log_parser.parse_io(StringIO.new(@sample)) do |request|
|
37
|
+
request[:remote_host].should == '127.0.0.1'
|
38
|
+
request[:timestamp].should == 20091123214747
|
39
|
+
request[:http_method].should == 'GET'
|
40
|
+
request[:path].should == '/css/stylesheet.css'
|
41
|
+
request[:http_version].should == '1.1'
|
42
|
+
request[:http_status].should == 200
|
43
|
+
request[:bytes_sent].should == 3782
|
44
|
+
request[:duration].should == 0.0024
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -54,6 +54,11 @@ describe RequestLogAnalyzer::FileFormat::Rails do
|
|
54
54
|
line = prefix + 'Processing PeopleController#index (for 1.1.1.1 at 2008-08-14 21:16:30) [GET]'
|
55
55
|
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET')
|
56
56
|
end
|
57
|
+
|
58
|
+
it "should parse a :processing line correctly when it contains ipv6 address" do
|
59
|
+
line = prefix + 'Processing PeopleController#index (for ::1 at 2008-08-14 21:16:30) [GET]'
|
60
|
+
@rails.should parse_line(line).as(:processing).and_capture(:controller => 'PeopleController', :action => 'index', :timestamp => 20080814211630, :method => 'GET')
|
61
|
+
end
|
57
62
|
|
58
63
|
it "should parse a Rails 2.1 style :completed line correctly" do
|
59
64
|
line = prefix + 'Completed in 0.21665 (4 reqs/sec) | Rendering: 0.00926 (4%) | DB: 0.00000 (0%) | 200 OK [http://demo.nu/employees]'
|
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.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-02 00:00:00 +01:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.1.0
|
35
35
|
version:
|
36
|
-
description: " Request log analyzer's purpose is to find
|
36
|
+
description: " Request log analyzer's purpose is to find out how your web application is being used, how it performs and to\n focus your optimization efforts. This tool will parse all requests in the application's log file and aggregate the \n information. Once it is finished parsing the log file(s), it will show the requests that take op most server time \n using various metrics. It can also insert all parsed request information into a database so you can roll your own\n analysis. It supports Rails-, Merb- and Rack-based applications logs, Apache and Amazon S3 access logs and MySQL \n slow query logs out of the box, but file formats of other applications can easily be supported by supplying an \n easy to write log file format definition.\n"
|
37
37
|
email:
|
38
38
|
- willem@railsdoctors.com
|
39
39
|
- bart@railsdoctors.com
|
@@ -44,8 +44,8 @@ extensions: []
|
|
44
44
|
extra_rdoc_files:
|
45
45
|
- README.rdoc
|
46
46
|
files:
|
47
|
-
- lib/request_log_analyzer/output/html.rb
|
48
47
|
- spec/unit/tracker/hourly_spread_spec.rb
|
48
|
+
- lib/request_log_analyzer/output/html.rb
|
49
49
|
- DESIGN.rdoc
|
50
50
|
- spec/fixtures/rails_unordered.log
|
51
51
|
- spec/fixtures/multiple_files_1.log
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/request_log_analyzer/aggregator.rb
|
61
61
|
- spec/fixtures/decompression.log
|
62
62
|
- lib/request_log_analyzer/file_format/apache.rb
|
63
|
+
- spec/unit/file_format/rack_format_spec.rb
|
63
64
|
- spec/fixtures/decompression.log.gz
|
64
65
|
- lib/request_log_analyzer/tracker/frequency.rb
|
65
66
|
- lib/request_log_analyzer/tracker/duration.rb
|
@@ -136,6 +137,7 @@ files:
|
|
136
137
|
- spec/unit/tracker/traffic_tracker_spec.rb
|
137
138
|
- lib/request_log_analyzer/tracker/timespan.rb
|
138
139
|
- spec/unit/controller/log_processor_spec.rb
|
140
|
+
- spec/fixtures/sinatra.log
|
139
141
|
- spec/unit/filter/field_filter_spec.rb
|
140
142
|
- spec/fixtures/merb_prefixed.log
|
141
143
|
- lib/request_log_analyzer/log_processor.rb
|
@@ -194,11 +196,12 @@ rubyforge_project: r-l-a
|
|
194
196
|
rubygems_version: 1.3.5
|
195
197
|
signing_key:
|
196
198
|
specification_version: 3
|
197
|
-
summary: A command line tool to analyze request logs for Apache, Rails, Merb and other web application servers
|
199
|
+
summary: A command line tool to analyze request logs for Apache, Rails, Merb, MySQL and other web application servers
|
198
200
|
test_files:
|
199
201
|
- spec/unit/tracker/hourly_spread_spec.rb
|
200
202
|
- spec/unit/file_format/amazon_s3_format_spec.rb
|
201
203
|
- spec/unit/database/base_class_spec.rb
|
204
|
+
- spec/unit/file_format/rack_format_spec.rb
|
202
205
|
- spec/unit/filter/filter_spec.rb
|
203
206
|
- spec/unit/tracker/count_tracker_spec.rb
|
204
207
|
- spec/unit/database/connection_spec.rb
|