sms-logparser 0.15.5 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sms-logparser/cli.rb +1 -8
- data/lib/sms-logparser/log_message.rb +30 -1
- data/lib/sms-logparser/parser.rb +30 -54
- data/lib/sms-logparser/version.rb +1 -1
- data/spec/log_message_spec.rb +68 -15
- data/spec/parser_spec.rb +8 -67
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bea26f8fa837033f39519a94d4f9b2b68b349bf
|
4
|
+
data.tar.gz: 1114c3f8fa841321e2a5f832cfc49db97f70bc9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d02d35532f58503c974ebc3cfaff6ae014c12204db91cb9a70a4e8eb57a71d26d2c35213ba3b6764eeb5141ec3d917d4bb17063326f84d55dcd27ab80dbdc1d
|
7
|
+
data.tar.gz: c4c1406cc2a8990cc2112b041f59c954908423f3c336fcda323009164cf5a8e7ab498ea2c059037d658bb277af9d42d8dbdb404027e7f958e8bfed45a23807c9
|
data/lib/sms-logparser/cli.rb
CHANGED
@@ -36,18 +36,11 @@ module SmsLogparser
|
|
36
36
|
desc: "Accumulate and cache results and send totals"
|
37
37
|
option :concurrency, type: :numeric, default: 4, aliases: %w(-C),
|
38
38
|
desc: "How many threads to use in parallel when sending cached results"
|
39
|
-
option :webcast_traffic_correction, type: :numeric, aliases: %w(-W),
|
40
|
-
desc: "Correction factor for webcast traffic"
|
41
|
-
option :mobile_traffic_correction, type: :numeric, aliases: %w(-M),
|
42
|
-
desc: "Correction factor for mobile traffic"
|
43
|
-
option :podcast_traffic_correction, type: :numeric, aliases: %w(-P),
|
44
|
-
desc: "Correction factor for podcast traffic"
|
45
39
|
def parse
|
46
40
|
start_message = "Parser started"
|
47
41
|
start_message += options[:simulate] ? " in simulation mode." : "."
|
48
42
|
logger.debug("Parser options: #{options.inspect}")
|
49
43
|
logger.info(start_message)
|
50
|
-
parser = Parser.new(options)
|
51
44
|
cache = DataCache.new if options[:accumulate]
|
52
45
|
mysql = Mysql.new(options)
|
53
46
|
if !options[:simulate] && mysql.parser_running?
|
@@ -67,7 +60,7 @@ module SmsLogparser
|
|
67
60
|
mysql.get_entries(last_id: state[:last_event_id], limit: options[:limit]) do |entries|
|
68
61
|
logger.info { "Getting log messages from database..." }
|
69
62
|
entries.each do |entry|
|
70
|
-
|
63
|
+
Parser.extract_data_from_msg(entry['Message']) do |data|
|
71
64
|
if data.size > 0
|
72
65
|
data.each do |data_entry|
|
73
66
|
if options[:accumulate]
|
@@ -1,7 +1,36 @@
|
|
1
1
|
module SmsLogparser
|
2
2
|
class LogMessage
|
3
|
+
|
4
|
+
attr_reader :message
|
5
|
+
|
3
6
|
def initialize(message)
|
4
|
-
|
7
|
+
# reove double slashes from message
|
8
|
+
@message = message.squeeze('/')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.match?(message)
|
12
|
+
if match = message.match(/\/content\/\d+\/\d+\/\d+\/(\S*).+(200|206)/)
|
13
|
+
# ignore detect.mp4
|
14
|
+
return true unless match[1] =~ /detect.mp4/i
|
15
|
+
end
|
16
|
+
false
|
17
|
+
end
|
18
|
+
|
19
|
+
# see https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent
|
20
|
+
# for mobile browser detection
|
21
|
+
def self.get_type(user_agent)
|
22
|
+
case user_agent
|
23
|
+
when /.*(iTunes).*/i
|
24
|
+
'PODCAST'
|
25
|
+
when /.*(Mobi|IEMobile|Mobile Safari|iPhone|iPod|iPad|Android|BlackBerry|Opera Mini).*/
|
26
|
+
'MOBILE'
|
27
|
+
else
|
28
|
+
'WEBCAST'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def type
|
33
|
+
LogMessage.get_type(user_agent)
|
5
34
|
end
|
6
35
|
|
7
36
|
def match
|
data/lib/sms-logparser/parser.rb
CHANGED
@@ -1,74 +1,50 @@
|
|
1
1
|
module SmsLogparser
|
2
|
-
|
2
|
+
module Parser
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def logger
|
7
|
+
SmsLogparser::Loggster.instance
|
7
8
|
end
|
8
9
|
|
9
10
|
def extract_data_from_msg(message)
|
10
11
|
data = []
|
11
|
-
if
|
12
|
-
|
12
|
+
if LogMessage.match?(message)
|
13
|
+
logger.debug { "Parser MATCH: #{message}" }
|
13
14
|
log_message = LogMessage.new(message)
|
14
|
-
|
15
|
-
|
15
|
+
if log_message.match
|
16
|
+
data << Parser.extract_usage_data(log_message)
|
17
|
+
data << Parser.extract_visit(log_message)
|
18
|
+
data.compact! # remove nil values
|
16
19
|
else
|
17
|
-
|
18
|
-
data << log_message.account_info.merge(
|
19
|
-
type: "TRAFFIC_#{type}",
|
20
|
-
value: (log_message.bytes * traffic_correction_factor(type)).round(0)
|
21
|
-
)
|
22
|
-
if log_message.status == 200 &&
|
23
|
-
(log_message.file_extname =~ /\.(mp3|mp4|flv|f4v)/ ||
|
24
|
-
log_message.file == 'index.m3u8')
|
25
|
-
data << log_message.account_info.merge(
|
26
|
-
type: "VISITORS_#{type}",
|
27
|
-
value: 1,
|
28
|
-
)
|
29
|
-
end
|
20
|
+
logger.warn { "Can't extract data from message: #{message}" }
|
30
21
|
end
|
31
22
|
else
|
32
|
-
|
33
|
-
end
|
34
|
-
return data unless block_given?
|
35
|
-
yield data
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.match?(message)
|
39
|
-
match = message.match(/\/content\/\d+\/\d+\/\d+\/(\S*).+(200|206)/)
|
40
|
-
# ignore detect.mp4
|
41
|
-
if match
|
42
|
-
return true unless match[1] =~ /detect.mp4/i
|
23
|
+
logger.debug { "Parser IGNORE: #{message}" }
|
43
24
|
end
|
44
|
-
|
25
|
+
yield data if block_given?
|
26
|
+
data
|
45
27
|
end
|
46
28
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
'PODCAST'
|
53
|
-
when /.*(Mobi|IEMobile|Mobile Safari|iPhone|iPod|iPad|Android|BlackBerry|Opera Mini).*/
|
54
|
-
'MOBILE'
|
55
|
-
else
|
56
|
-
'WEBCAST'
|
57
|
-
end
|
29
|
+
def extract_usage_data(log_message)
|
30
|
+
log_message.account_info.merge(
|
31
|
+
type: "TRAFFIC_#{log_message.type}",
|
32
|
+
value: log_message.bytes
|
33
|
+
)
|
58
34
|
end
|
59
35
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
36
|
+
def extract_visit(log_message)
|
37
|
+
if log_message.status == 200 &&
|
38
|
+
(log_message.file_extname =~ /\.(mp3|mp4|flv|f4v)/ || log_message.file == 'index.m3u8')
|
39
|
+
visit_data = log_message.account_info.merge(
|
40
|
+
type: "VISITORS_#{log_message.type}",
|
41
|
+
value: 1
|
42
|
+
)
|
43
|
+
logger.debug { "Counting visit for message: #{log_message.message}" }
|
68
44
|
else
|
69
|
-
|
45
|
+
logger.debug { "Not counting visit for message: #{log_message.message}" }
|
70
46
|
end
|
71
|
-
|
47
|
+
visit_data || nil
|
72
48
|
end
|
73
49
|
|
74
50
|
end # class
|
data/spec/log_message_spec.rb
CHANGED
@@ -2,6 +2,65 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SmsLogparser::LogMessage do
|
4
4
|
|
5
|
+
%w(f4v flv mp4 mp3 ts m3u8 jpg js css m4a png sid).each do |extension|
|
6
|
+
it "matches #{extension} files" do
|
7
|
+
SmsLogparser::LogMessage.match?(
|
8
|
+
"GET /content/2/719/54986/file.#{extension} HTTP/1.1\" 200 6741309 "
|
9
|
+
).must_equal true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
%w(200 206).each do |status|
|
14
|
+
it "does match status code #{status}" do
|
15
|
+
SmsLogparser::LogMessage.match?(
|
16
|
+
"GET /content/2/719/54986/file.mp4 HTTP/1.1\" #{status} 50000 "
|
17
|
+
).must_equal true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
%w(404 500 304).each do |status|
|
22
|
+
it "does not match status code #{status}" do
|
23
|
+
SmsLogparser::LogMessage.match?(
|
24
|
+
"GET /content/2/719/54986/file.mp4 HTTP/1.1\" #{status} 50000 "
|
25
|
+
).must_equal false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
%w(contents public index assets).each do |dir|
|
30
|
+
it "does not match directories other than /content" do
|
31
|
+
SmsLogparser::LogMessage.match?(
|
32
|
+
"GET /#{dir}/2/719/54986/file.mp4 HTTP/1.1\" 200 50000 "
|
33
|
+
).must_equal false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not match for 'detect.mp4' files" do
|
38
|
+
SmsLogparser::LogMessage.match?(
|
39
|
+
"GET /content/2/719/54986/detect.mp4 HTTP/1.1\" 200 128 "
|
40
|
+
).must_equal false
|
41
|
+
end
|
42
|
+
|
43
|
+
[
|
44
|
+
"Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
|
45
|
+
"Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0",
|
46
|
+
"Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; es-ES) Presto/2.9.201 Version/11.50",
|
47
|
+
"Mozilla/5.0 (Linux; Android 4.4.2); Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047",
|
48
|
+
"Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)",
|
49
|
+
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3"
|
50
|
+
].each do |mobile_agent|
|
51
|
+
it "traffic type for mobile user agents is TRAFFIC_MOBILE (#{mobile_agent})" do
|
52
|
+
SmsLogparser::LogMessage.get_type(mobile_agent).must_equal "MOBILE"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
[
|
57
|
+
'127.0.0.1 - - [13/Apr/2014:05:33:23 +0200] "GET /content/51/52/42481/simvid_1.mp4 HTTP/1.1" 206 7865189 "-" "iTunes/11.1.5 (Windows; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)) AppleWebKit/537.60.11"'
|
58
|
+
].each do |podcast_agent|
|
59
|
+
it "traffic type for mobile user agents is TRAFFIC_PODCAST (#{podcast_agent})" do
|
60
|
+
SmsLogparser::LogMessage.get_type(podcast_agent).must_equal "PODCAST"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
5
64
|
it "can extract the correct values from messages without arg string" do
|
6
65
|
log_message = SmsLogparser::LogMessage.new('127.0.0.1 - - [13/Apr/2014:05:33:23 +0200] "GET /content/51/102/42481/simvid_1.mp4 HTTP/1.1" 206 7865189 "-" "iTunes/11.1.5 (Windows; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)) AppleWebKit/537.60.11"')
|
7
66
|
log_message.customer_id.must_equal '51'
|
@@ -43,21 +102,15 @@ describe SmsLogparser::LogMessage do
|
|
43
102
|
|
44
103
|
it "does not fail on double slashes" do
|
45
104
|
log_message = SmsLogparser::LogMessage.new('- - [23/Apr/2014:23:01:24 +0200] "GET /content/244/245/42601//player_logo.jpg?0.19035581778734922 HTTP/1.1" 200 21671 "http://blick.simplex.tv/content/244/245/42601/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36"')
|
46
|
-
log_message.customer_id.must_equal
|
47
|
-
log_message.author_id.must_equal
|
48
|
-
log_message.project_id.must_equal
|
49
|
-
log_message.status.must_equal
|
50
|
-
log_message.bytes.must_equal
|
51
|
-
log_message.file.must_equal
|
52
|
-
log_message.args.must_equal
|
53
|
-
log_message.file_extname.must_equal
|
54
|
-
log_message.user_agent.must_equal
|
55
|
-
#log_message.status.must_equal 200
|
56
|
-
#log_message.bytes.must_equal 1181
|
57
|
-
#log_message.file.must_equal 'player_logo.jpg'
|
58
|
-
#log_message.args.must_equal '0.19035581778734922'
|
59
|
-
#log_message.file_extname.must_equal 'jpg'
|
60
|
-
#log_message.user_agent.must_equal 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36'
|
105
|
+
log_message.customer_id.must_equal '244'
|
106
|
+
log_message.author_id.must_equal '245'
|
107
|
+
log_message.project_id.must_equal '42601'
|
108
|
+
log_message.status.must_equal 200
|
109
|
+
log_message.bytes.must_equal 21671
|
110
|
+
log_message.file.must_equal 'player_logo.jpg'
|
111
|
+
log_message.args.must_equal '0.19035581778734922'
|
112
|
+
log_message.file_extname.must_equal '.jpg'
|
113
|
+
log_message.user_agent.must_equal 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36'
|
61
114
|
end
|
62
115
|
|
63
116
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -2,68 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SmsLogparser::Parser do
|
4
4
|
|
5
|
-
%w(f4v flv mp4 mp3 ts m3u8 jpg js css m4a png sid).each do |extension|
|
6
|
-
it "matches #{extension} files" do
|
7
|
-
SmsLogparser::Parser.match?(
|
8
|
-
"GET /content/2/719/54986/file.#{extension} HTTP/1.1\" 200 6741309 "
|
9
|
-
).must_equal true
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
%w(200 206).each do |status|
|
14
|
-
it "does match status code #{status}" do
|
15
|
-
SmsLogparser::Parser.match?(
|
16
|
-
"GET /content/2/719/54986/file.mp4 HTTP/1.1\" #{status} 50000 "
|
17
|
-
).must_equal true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
%w(404 500 304).each do |status|
|
22
|
-
it "does not match status code #{status}" do
|
23
|
-
SmsLogparser::Parser.match?(
|
24
|
-
"GET /content/2/719/54986/file.mp4 HTTP/1.1\" #{status} 50000 "
|
25
|
-
).must_equal false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
%w(contents public index assets).each do |dir|
|
30
|
-
it "does not match directories other than /content" do
|
31
|
-
SmsLogparser::Parser.match?(
|
32
|
-
"GET /#{dir}/2/719/54986/file.mp4 HTTP/1.1\" 200 50000 "
|
33
|
-
).must_equal false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "does not match for 'detect.mp4' files" do
|
38
|
-
SmsLogparser::Parser.match?(
|
39
|
-
"GET /content/2/719/54986/detect.mp4 HTTP/1.1\" 200 128 "
|
40
|
-
).must_equal false
|
41
|
-
end
|
42
|
-
|
43
|
-
[
|
44
|
-
"Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
|
45
|
-
"Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0",
|
46
|
-
"Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; es-ES) Presto/2.9.201 Version/11.50",
|
47
|
-
"Mozilla/5.0 (Linux; Android 4.4.2); Nexus 5 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36 OPR/20.0.1396.72047",
|
48
|
-
"Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)",
|
49
|
-
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3"
|
50
|
-
].each do |mobile_agent|
|
51
|
-
it "traffic type for mobile user agents is TRAFFIC_MOBILE (#{mobile_agent})" do
|
52
|
-
SmsLogparser::Parser.get_type(mobile_agent).must_equal "MOBILE"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
[
|
57
|
-
'127.0.0.1 - - [13/Apr/2014:05:33:23 +0200] "GET /content/51/52/42481/simvid_1.mp4 HTTP/1.1" 206 7865189 "-" "iTunes/11.1.5 (Windows; Microsoft Windows 7 Home Premium Edition Service Pack 1 (Build 7601)) AppleWebKit/537.60.11"'
|
58
|
-
].each do |podcast_agent|
|
59
|
-
it "traffic type for mobile user agents is TRAFFIC_PODCAST (#{podcast_agent})" do
|
60
|
-
SmsLogparser::Parser.get_type(podcast_agent).must_equal "PODCAST"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
5
|
it "count index.m3u8 with status 200 and user agent iPhone as mobile visit" do
|
65
6
|
message = '- - [22/Apr/2014:17:44:17 +0200] "GET /content/51/52/42701/index.m3u8 HTTP/1.1" 200 319 "-" "AppleCoreMedia/1.0.0.11D167 (iPhone; U; CPU OS 7_1 like Mac OS X; de_de)"'
|
66
|
-
data = SmsLogparser::Parser.
|
7
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
67
8
|
data[1][:customer_id].must_equal "51"
|
68
9
|
data[1][:author_id].must_equal "52"
|
69
10
|
data[1][:project_id].must_equal "42701"
|
@@ -73,7 +14,7 @@ describe SmsLogparser::Parser do
|
|
73
14
|
|
74
15
|
it "count *.flv with status 200 and user agent Android as mobile visit" do
|
75
16
|
message = ' - - [22/Apr/2014:17:44:27 +0200] "GET /content/51/52/42709/simvid_1_40.flv HTTP/1.1" 200 96259 "http://blick.simplex.tv/NubesPlayer/index.html?cID=51&aID=52&pID=42709&autostart=false&themeColor=d6081c&embed=1&configUrl=http://f.blick.ch/resources/61786/ver1-0/js/xtendxIframeStatsSmartphone.js?adtechID=3522740&language=de&quality=40&hideHD=true&progressiveDownload=true" "Mozilla/5.0 (Linux; Android 4.4.2; C6903 Build/14.3.A.0.757) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36"'
|
76
|
-
data = SmsLogparser::Parser.
|
17
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
77
18
|
data[1][:customer_id].must_equal "51"
|
78
19
|
data[1][:author_id].must_equal "52"
|
79
20
|
data[1][:project_id].must_equal "42709"
|
@@ -83,7 +24,7 @@ describe SmsLogparser::Parser do
|
|
83
24
|
|
84
25
|
it "count *.mp4 with status 200 and user agent Android as mobile visit" do
|
85
26
|
message = '- - [22/Apr/2014:17:44:21 +0200] "GET /content/51/52/42701/simvid_1.mp4 HTTP/1.1" 200 2644715 "-" "Samsung GT-I9505 stagefright/1.2 (Linux;Android 4.4.2)"'
|
86
|
-
data = SmsLogparser::Parser.
|
27
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
87
28
|
data[1][:customer_id].must_equal "51"
|
88
29
|
data[1][:author_id].must_equal "52"
|
89
30
|
data[1][:project_id].must_equal "42701"
|
@@ -93,7 +34,7 @@ describe SmsLogparser::Parser do
|
|
93
34
|
|
94
35
|
it "count *.flv with status 200 and user agent Firefox on Windows as webcast visit" do
|
95
36
|
message = '- - [22/Apr/2014:18:00:50 +0200] "GET /content/51/52/42431/simvid_1_40.flv HTTP/1.1" 200 6742274 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"'
|
96
|
-
data = SmsLogparser::Parser.
|
37
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
97
38
|
data[1][:customer_id].must_equal "51"
|
98
39
|
data[1][:author_id].must_equal "52"
|
99
40
|
data[1][:project_id].must_equal "42431"
|
@@ -103,7 +44,7 @@ describe SmsLogparser::Parser do
|
|
103
44
|
|
104
45
|
it "count traffic with status 206 and a argumenst string and user agent Firefox on Windows as webcast visit" do
|
105
46
|
message = '- - [23/Apr/2014:17:36:33 +0200] "GET /content/51/52/42721/simvid_1_40.flv?position=22 HTTP/1.1" 206 100708 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0"'
|
106
|
-
data = SmsLogparser::Parser.
|
47
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
107
48
|
data.first[:customer_id].must_equal "51"
|
108
49
|
data.first[:author_id].must_equal "52"
|
109
50
|
data.first[:project_id].must_equal "42721"
|
@@ -113,7 +54,7 @@ describe SmsLogparser::Parser do
|
|
113
54
|
|
114
55
|
it "count traffic with status 200 and no file from bot as webcast visit" do
|
115
56
|
message = '- - [23/Apr/2014:17:47:32 +0200] "GET /content/51/52/42624/ HTTP/1.1" 200 1181 "-" "Googlebot-Video/1.0"'
|
116
|
-
data = SmsLogparser::Parser.
|
57
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
117
58
|
data.size.must_equal 1
|
118
59
|
data.first[:customer_id].must_equal "51"
|
119
60
|
data.first[:author_id].must_equal "52"
|
@@ -124,13 +65,13 @@ describe SmsLogparser::Parser do
|
|
124
65
|
|
125
66
|
it "do not count *.css with status 200 as visit" do
|
126
67
|
message = '- - [22/Apr/2014:18:00:50 +0200] "GET /content/51/52/42431/application.css HTTP/1.1" 200 192 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"'
|
127
|
-
data = SmsLogparser::Parser.
|
68
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
128
69
|
data.size.must_equal 1
|
129
70
|
end
|
130
71
|
|
131
72
|
it "do not count status 206 as visit" do
|
132
73
|
message = '- - [22/Apr/2014:18:00:50 +0200] "GET /content/51/52/42431/simvid_1_40.flv HTTP/1.1" 206 19289 "http://blick.simplex.tv/NubesPlayer/player.swf" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"'
|
133
|
-
data = SmsLogparser::Parser.
|
74
|
+
data = SmsLogparser::Parser.extract_data_from_msg(message)
|
134
75
|
data.size.must_equal 1
|
135
76
|
end
|
136
77
|
|