log_analysis 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/log_analysis.rb +2 -0
- data/lib/log_analysis/preprocess.rb +6 -4
- data/lib/log_analysis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90d23db656f54440f9e7b66a4bb83d6eb3ee82f6d15095cb61f1124c90843b81
|
4
|
+
data.tar.gz: 47b6770970bbf2fe5ecb8a9fee5164e29399d5f28c45373e70fac468c3cf3650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eba66ff44c7a018b307af73b9c1b2146c1e55f4a29381864759a3d80a030267911c2e101f03c366fa75d30b4e4bff3840f216d3966f40051756bcf2c7d76d0b6
|
7
|
+
data.tar.gz: 9d1bc9317752d18d721345fa6af4f9161e5c2a2b3843177f64dc2a19095618e5897da585f7b1c1ef1a2d6f8180ec164303cc7fb3bbd34443258564b3561c7b4a
|
data/Gemfile.lock
CHANGED
data/lib/log_analysis.rb
CHANGED
@@ -43,6 +43,8 @@ class LogAnalysis
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def move_data
|
46
|
+
return unless File.directory?('/home/app/data/waazabag/')
|
47
|
+
|
46
48
|
system('mv', "transform_data_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
|
47
49
|
system('mv', "output_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
|
48
50
|
system('mv', "map_uri_#{Time.now.strftime('%Y%m%d')}.txt", '/home/app/data/waazabag/')
|
@@ -13,17 +13,19 @@ module PreProcess
|
|
13
13
|
CONVERT_RECORD = { 'nginx' => 'convert_nginx_logs', 'apache' => 'convert_apache_logs', 'default' => 'to_records' }.freeze
|
14
14
|
|
15
15
|
def self.input(file_path, type)
|
16
|
-
@users
|
16
|
+
@users = []
|
17
|
+
text_file = File.readlines(file_path)
|
17
18
|
|
18
|
-
|
19
|
+
text_file.each_with_object([]).with_index do |(line, arr), i|
|
19
20
|
preprocessed_log = type.nil? ? line.gsub(/[\t]/i, ' ').chomp! : line
|
20
21
|
record_params = send(CONVERT_RECORD[type.nil? ? 'nginx' : type], preprocessed_log)
|
21
22
|
record = Record.new(record_params) if record_params && preprocessed_log
|
22
|
-
record = yield(record) if block_given?
|
23
|
+
record = yield(record) if block_given? && record
|
23
24
|
|
24
25
|
arr.push(record) if record && record.status_200? && record.method_get? && record.uri_without_data && !record.robot?
|
25
26
|
|
26
|
-
|
27
|
+
system('clear')
|
28
|
+
puts "#{((i.to_f / text_file.size) * 100).round}/100"
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
data/lib/log_analysis/version.rb
CHANGED