request-log-analyzer 1.13.0 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/bin/request-log-analyzer +4 -0
- data/lib/request_log_analyzer/aggregator/summarizer.rb +1 -1
- data/lib/request_log_analyzer/controller.rb +5 -1
- data/lib/request_log_analyzer/file_format.rb +1 -0
- data/lib/request_log_analyzer/file_format/delayed_job4.rb +54 -0
- data/lib/request_log_analyzer/request.rb +1 -2
- data/lib/request_log_analyzer/version.rb +1 -1
- data/spec/integration/mailer_spec.rb +30 -0
- data/spec/unit/file_format/delayed_job4_format_spec.rb +52 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c24635e41e1a2f3e4c11e6f4814cd9381b0d5073
|
4
|
+
data.tar.gz: 0b70d1e886d4a1ca41361023aee81d7d63acb1fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 605898a6b50c9e528c3807e92a3fa98effdd7ddbcb85391312e15f30e101612e10f0c6710891b1804d94aa25cc5a99cbd37fd90dcad7da0c91d400e89822b3da
|
7
|
+
data.tar.gz: e617b1756392fe884a0355e06281302d32c6899832482e4f750b237dae34e75763e702b1bc500d6a297a25591dabfa1a1859569ed417cab48ef008a37dc74776
|
data/.travis.yml
CHANGED
@@ -10,7 +10,7 @@ rvm:
|
|
10
10
|
- ruby-head
|
11
11
|
- jruby-19mode
|
12
12
|
- jruby-head
|
13
|
-
- rbx
|
13
|
+
- rbx-2
|
14
14
|
gemfile:
|
15
15
|
- Gemfile.activerecord3
|
16
16
|
- Gemfile.activerecord4
|
@@ -18,7 +18,7 @@ matrix:
|
|
18
18
|
allow_failures:
|
19
19
|
- rvm: jruby-head
|
20
20
|
- rvm: ruby-head
|
21
|
-
- rvm: rbx
|
21
|
+
- rvm: rbx-2
|
22
22
|
notifications:
|
23
23
|
email:
|
24
24
|
- info@railsdoctors.com
|
data/bin/request-log-analyzer
CHANGED
@@ -36,6 +36,8 @@ begin
|
|
36
36
|
command_line.option(:file, :alias => :e)
|
37
37
|
command_line.option(:mail, :alias => :m)
|
38
38
|
command_line.option(:mailhost, :default => 'localhost')
|
39
|
+
command_line.option(:mailfrom)
|
40
|
+
command_line.option(:mailfrom_name)
|
39
41
|
command_line.option(:mailsubject)
|
40
42
|
command_line.option(:parse_strategy, :default => 'assume-correct')
|
41
43
|
command_line.option(:yaml)
|
@@ -88,6 +90,8 @@ rescue CommandLine::Error => e
|
|
88
90
|
puts " --file <filename> Redirect output to file."
|
89
91
|
puts " --mail <emailaddress> Send report to an email address."
|
90
92
|
puts " --mailhost <server> Use the given server as the SMTP server for sending email."
|
93
|
+
puts " --mailfrom <address> Overwrite default email sender address."
|
94
|
+
puts " --mailfrom-name <name> Overwrite default email sender name."
|
91
95
|
puts " --mailsubject <text> Overwrite default mailsubject."
|
92
96
|
puts " --no-progress Hide the progress bar."
|
93
97
|
puts " --output <format> Output format. Supports 'html' and 'fixed_width'."
|
@@ -109,7 +109,7 @@ module RequestLogAnalyzer::Aggregator
|
|
109
109
|
output.with_style(:cell_separator => false) do
|
110
110
|
output.table({:width => 20}, {:font => :bold}) do |rows|
|
111
111
|
source.processed_files.each do |f|
|
112
|
-
rows << ['
|
112
|
+
rows << ['Processed File:', f]
|
113
113
|
end
|
114
114
|
rows << ['Parsed lines:', source.parsed_lines]
|
115
115
|
rows << ['Skipped lines:', source.skipped_lines]
|
@@ -43,6 +43,8 @@ module RequestLogAnalyzer
|
|
43
43
|
options[:report_sort] = arguments[:report_sort]
|
44
44
|
options[:report_amount] = arguments[:report_amount]
|
45
45
|
options[:mailhost] = arguments[:mailhost]
|
46
|
+
options[:mailfrom] = arguments[:mailfrom]
|
47
|
+
options[:mailfrom_name] = arguments[:mailfrom_name]
|
46
48
|
options[:mailsubject] = arguments[:mailsubject]
|
47
49
|
options[:silent] = arguments[:silent]
|
48
50
|
options[:parse_strategy] = arguments[:parse_strategy]
|
@@ -106,6 +108,8 @@ module RequestLogAnalyzer
|
|
106
108
|
# * <tt>:format</tt> :rails, {:apache => 'FORMATSTRING'}, :merb, :amazon_s3, :mysql or RequestLogAnalyzer::FileFormat class. (Defaults to :rails).
|
107
109
|
# * <tt>:mail</tt> Email the results to this email address.
|
108
110
|
# * <tt>:mailhost</tt> Email the results to this mail server.
|
111
|
+
# * <tt>:mailfrom</tt> Set the Email sender address.
|
112
|
+
# * <tt>:mailfrom_alias</tt> Set the Email sender name.
|
109
113
|
# * <tt>:mailsubject</tt> Email subject.
|
110
114
|
# * <tt>:no_progress</tt> Do not display the progress bar (increases parsing speed).
|
111
115
|
# * <tt>:output</tt> 'FixedWidth', 'HTML' or RequestLogAnalyzer::Output class. Defaults to 'FixedWidth'.
|
@@ -165,7 +169,7 @@ module RequestLogAnalyzer
|
|
165
169
|
output_object = %w[File StringIO].include?(options[:file].class.name) ? options[:file] : File.new(options[:file], "w+")
|
166
170
|
output_args = {:width => 80, :color => false, :characters => :ascii, :sort => output_sort, :amount => output_amount }
|
167
171
|
elsif options[:mail]
|
168
|
-
output_object = RequestLogAnalyzer::Mailer.new(options[:mail], options[:mailhost], :subject => options[:mailsubject])
|
172
|
+
output_object = RequestLogAnalyzer::Mailer.new(options[:mail], options[:mailhost], :subject => options[:mailsubject], :from => options[:mailfrom], :from_alias => options[:mailfrom_name])
|
169
173
|
output_args = {:width => 80, :color => false, :characters => :ascii, :sort => output_sort, :amount => output_amount }
|
170
174
|
else
|
171
175
|
output_object = STDOUT
|
@@ -15,6 +15,7 @@ module RequestLogAnalyzer::FileFormat
|
|
15
15
|
autoload :DelayedJob2, 'request_log_analyzer/file_format/delayed_job2'
|
16
16
|
autoload :DelayedJob21, 'request_log_analyzer/file_format/delayed_job21'
|
17
17
|
autoload :DelayedJob3, 'request_log_analyzer/file_format/delayed_job3'
|
18
|
+
autoload :DelayedJob4, 'request_log_analyzer/file_format/delayed_job4'
|
18
19
|
autoload :Apache, 'request_log_analyzer/file_format/apache'
|
19
20
|
autoload :AmazonS3, 'request_log_analyzer/file_format/amazon_s3'
|
20
21
|
autoload :W3c, 'request_log_analyzer/file_format/w3c'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module RequestLogAnalyzer::FileFormat
|
2
|
+
|
3
|
+
# The DelayedJob4 file format parsed log files that are created by DelayedJob 4.0 or higher.
|
4
|
+
# By default, the log file can be found in RAILS_ROOT/log/delayed_job.log
|
5
|
+
class DelayedJob4 < Base
|
6
|
+
|
7
|
+
extend CommonRegularExpressions
|
8
|
+
|
9
|
+
line_definition :job_completed do |line|
|
10
|
+
line.header = true
|
11
|
+
line.footer = true
|
12
|
+
line.regexp = /(#{timestamp('%Y-%m-%dT%H:%M:%S%z')}): \[Worker\(\S+ host:(#{hostname_or_ip_address}) pid:(\d+)\)\] Job (.+) \(id=\d+\) COMPLETED after (\d+\.\d+)/
|
13
|
+
line.capture(:timestamp).as(:timestamp)
|
14
|
+
line.capture(:host)
|
15
|
+
line.capture(:pid).as(:integer)
|
16
|
+
line.capture(:job)
|
17
|
+
line.capture(:duration).as(:duration, :unit => :sec)
|
18
|
+
end
|
19
|
+
|
20
|
+
line_definition :job_failed do |line|
|
21
|
+
line.header = true
|
22
|
+
line.footer = true
|
23
|
+
line.regexp = /(#{timestamp('%Y-%m-%dT%H:%M:%S%z')}): \[Worker\(\S+ host:(#{hostname_or_ip_address}) pid:(\d+)\)\] Job (.+) FAILED \((\d+) prior attempts\) with (.+)/
|
24
|
+
line.capture(:timestamp).as(:timestamp)
|
25
|
+
line.capture(:host)
|
26
|
+
line.capture(:pid).as(:integer)
|
27
|
+
line.capture(:job)
|
28
|
+
line.capture(:attempts).as(:integer)
|
29
|
+
line.capture(:error)
|
30
|
+
end
|
31
|
+
|
32
|
+
line_definition :job_deleted do |line|
|
33
|
+
line.header = true
|
34
|
+
line.footer = true
|
35
|
+
line.regexp = /(#{timestamp('%Y-%m-%dT%H:%M:%S%z')}): \[Worker\(\S+ host:(#{hostname_or_ip_address}) pid:(\d+)\)\] Job (.+) REMOVED permanently because of (\d+) consecutive failures/
|
36
|
+
line.capture(:timestamp).as(:timestamp)
|
37
|
+
line.capture(:host)
|
38
|
+
line.capture(:pid).as(:integer)
|
39
|
+
line.capture(:job)
|
40
|
+
line.capture(:failures).as(:integer)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
report do |analyze|
|
45
|
+
analyze.timespan
|
46
|
+
analyze.hourly_spread
|
47
|
+
|
48
|
+
analyze.frequency :job, :line_type => :job_completed, :title => "Completed jobs"
|
49
|
+
analyze.frequency :job, :category => lambda { |r| "#{r[:job]} #{r[:error]}" }, :line_type => :job_failed, :title => "Failed jobs"
|
50
|
+
analyze.frequency :failures, :category => :job, :line_type => :job_deleted, :title => "Deleted jobs"
|
51
|
+
analyze.duration :duration, :category => :job, :line_type => :job_completed, :title => "Job duration"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -38,8 +38,7 @@ module RequestLogAnalyzer
|
|
38
38
|
# Converts :eval field, which should evaluate to a hash.
|
39
39
|
def convert_eval(value, capture_definition)
|
40
40
|
eval(sanitize_parameters(value)).inject({}) { |h, (k, v)| h[k.to_sym] = v; h}
|
41
|
-
|
42
|
-
rescue SyntaxError
|
41
|
+
rescue
|
43
42
|
nil
|
44
43
|
end
|
45
44
|
|
@@ -52,6 +52,36 @@ describe RequestLogAnalyzer, 'running mailer integration' do
|
|
52
52
|
find_string_in_file("Subject: TESTSUBJECT", @log_file).should_not be_nil
|
53
53
|
end
|
54
54
|
|
55
|
+
it "should allow a custom mail sender address" do
|
56
|
+
RequestLogAnalyzer::Controller.build(
|
57
|
+
:mail => 'root@localhost',
|
58
|
+
:mailhost => 'localhost:2525',
|
59
|
+
:mailfrom => 'customaddr@example.com',
|
60
|
+
:source_files => log_fixture(:rails_1x),
|
61
|
+
:format => RequestLogAnalyzer::FileFormat::Rails,
|
62
|
+
:no_progress => true
|
63
|
+
).run!
|
64
|
+
|
65
|
+
Process.wait # Wait for mailer to complete
|
66
|
+
|
67
|
+
find_string_in_file("From: Request-log-analyzer reporter <customaddr@example.com>", @log_file).should_not be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should allow a custom mail sender name" do
|
71
|
+
RequestLogAnalyzer::Controller.build(
|
72
|
+
:mail => 'root@localhost',
|
73
|
+
:mailhost => 'localhost:2525',
|
74
|
+
:mailfrom_name => 'Custom Name',
|
75
|
+
:source_files => log_fixture(:rails_1x),
|
76
|
+
:format => RequestLogAnalyzer::FileFormat::Rails,
|
77
|
+
:no_progress => true
|
78
|
+
).run!
|
79
|
+
|
80
|
+
Process.wait # Wait for mailer to complete
|
81
|
+
|
82
|
+
find_string_in_file("From: Custom Name <contact@railsdoctors.com>", @log_file).should_not be_nil
|
83
|
+
end
|
84
|
+
|
55
85
|
it "should send html mail" do
|
56
86
|
RequestLogAnalyzer::Controller.build(
|
57
87
|
:output => 'HTML',
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RequestLogAnalyzer::FileFormat::DelayedJob do
|
4
|
+
|
5
|
+
subject { RequestLogAnalyzer::FileFormat.load(:delayed_job4) }
|
6
|
+
|
7
|
+
it { should be_well_formed }
|
8
|
+
it { should have_line_definition(:job_completed).capturing(:timestamp, :duration, :host, :pid, :job) }
|
9
|
+
it { should have_line_definition(:job_failed).capturing(:timestamp, :host, :pid, :job, :attempts, :error) }
|
10
|
+
it { should have_line_definition(:job_deleted).capturing(:timestamp, :host, :pid, :job, :failures) }
|
11
|
+
it { should have(6).report_trackers }
|
12
|
+
|
13
|
+
|
14
|
+
describe '#parse_line' do
|
15
|
+
|
16
|
+
let(:job_completed_sample) { '2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob.create (id=534785) COMPLETED after 1.0676' }
|
17
|
+
let(:job_failed_sample) { '2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob.create (id=534785) FAILED (0 prior attempts) with SocketError: getaddrinfo: Name or service not known' }
|
18
|
+
let(:job_deleted_sample) { '2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob.create (id=534785) REMOVED permanently because of 25 consecutive failures' }
|
19
|
+
|
20
|
+
it { should parse_line(job_completed_sample).as(:job_completed).and_capture(
|
21
|
+
:timestamp => 20100517173735, :duration => 1.0676, :host => 'hostname.co.uk', :pid => 11888, :job => 'S3FileJob.create') }
|
22
|
+
|
23
|
+
it { should parse_line(job_failed_sample).as(:job_failed).and_capture(
|
24
|
+
:timestamp => 20100517173735, :host => 'hostname.co.uk', :pid => 11888, :job => 'S3FileJob.create (id=534785)', :attempts => 0, :error => "SocketError: getaddrinfo: Name or service not known") }
|
25
|
+
|
26
|
+
it { should parse_line(job_deleted_sample).as(:job_deleted).and_capture(
|
27
|
+
:timestamp => 20100517173735, :host => 'hostname.co.uk', :pid => 11888, :job => 'S3FileJob.create (id=534785)', :failures => 25) }
|
28
|
+
|
29
|
+
it { should_not parse_line('nonsense', 'a nonsense line') }
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe '#parse_io' do
|
34
|
+
let(:log_parser) { RequestLogAnalyzer::Source::LogParser.new(subject) }
|
35
|
+
|
36
|
+
it "should parse a batch of completed jobs without warnings" do
|
37
|
+
fragment = log_snippet(<<-EOLOG)
|
38
|
+
2010-05-17T17:36:44+0000: *** Starting job worker delayed_job host:hostname.co.uk pid:11888
|
39
|
+
2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob (id=534785) COMPLETED after 1.0676
|
40
|
+
2010-05-17T17:37:37+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob (id=534788) COMPLETED after 1.4407
|
41
|
+
2010-05-17T17:37:44+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob (id=534789) COMPLETED after 6.9374
|
42
|
+
2010-05-17T17:37:44+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] 3 jobs processed at 0.3163 j/s, 0 failed
|
43
|
+
2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob.create (id=534786) FAILED (25 prior attempts) with SocketError: getaddrinfo: Name or service not known
|
44
|
+
2010-05-17T17:37:35+0000: [Worker(delayed_job host:hostname.co.uk pid:11888)] Job S3FileJob.create (id=534799) REMOVED permanently because of 25 consecutive failures
|
45
|
+
2010-05-19T11:47:26+0000: Exiting...
|
46
|
+
EOLOG
|
47
|
+
|
48
|
+
log_parser.should_receive(:handle_request).exactly(5).times
|
49
|
+
log_parser.parse_io(fragment)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
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.13.
|
4
|
+
version: 1.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/request_log_analyzer/file_format/delayed_job2.rb
|
149
149
|
- lib/request_log_analyzer/file_format/delayed_job21.rb
|
150
150
|
- lib/request_log_analyzer/file_format/delayed_job3.rb
|
151
|
+
- lib/request_log_analyzer/file_format/delayed_job4.rb
|
151
152
|
- lib/request_log_analyzer/file_format/haproxy.rb
|
152
153
|
- lib/request_log_analyzer/file_format/merb.rb
|
153
154
|
- lib/request_log_analyzer/file_format/mysql.rb
|
@@ -235,6 +236,7 @@ files:
|
|
235
236
|
- spec/unit/file_format/delayed_job21_format_spec.rb
|
236
237
|
- spec/unit/file_format/delayed_job2_format_spec.rb
|
237
238
|
- spec/unit/file_format/delayed_job3_format_spec.rb
|
239
|
+
- spec/unit/file_format/delayed_job4_format_spec.rb
|
238
240
|
- spec/unit/file_format/delayed_job_format_spec.rb
|
239
241
|
- spec/unit/file_format/file_format_api_spec.rb
|
240
242
|
- spec/unit/file_format/format_autodetection_spec.rb
|
@@ -291,7 +293,7 @@ requirements:
|
|
291
293
|
- To use the database inserter, ActiveRecord and an appropriate database adapter are
|
292
294
|
required.
|
293
295
|
rubyforge_project: r-l-a
|
294
|
-
rubygems_version: 2.0.
|
296
|
+
rubygems_version: 2.0.14
|
295
297
|
signing_key:
|
296
298
|
specification_version: 4
|
297
299
|
summary: A command line tool to analyze request logs for Apache, Rails, Merb, MySQL
|
@@ -351,6 +353,7 @@ test_files:
|
|
351
353
|
- spec/unit/file_format/delayed_job21_format_spec.rb
|
352
354
|
- spec/unit/file_format/delayed_job2_format_spec.rb
|
353
355
|
- spec/unit/file_format/delayed_job3_format_spec.rb
|
356
|
+
- spec/unit/file_format/delayed_job4_format_spec.rb
|
354
357
|
- spec/unit/file_format/delayed_job_format_spec.rb
|
355
358
|
- spec/unit/file_format/file_format_api_spec.rb
|
356
359
|
- spec/unit/file_format/format_autodetection_spec.rb
|
@@ -378,4 +381,3 @@ test_files:
|
|
378
381
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
379
382
|
- spec/unit/tracker/tracker_api_spec.rb
|
380
383
|
- spec/unit/tracker/traffic_tracker_spec.rb
|
381
|
-
has_rdoc:
|