Skip to content

Commit

Permalink
add there also product detection
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 14, 2020
1 parent b92fc55 commit 0a1d241
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ytools/y2tool/analyze_logs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ def find_modules(result, content)
end
end

def find_base_product(result, content)
# use os-release. Line looks like:
# 2014-05-19 09:31:54 <1> linux(2541) [Ruby] modules/Misc.rb:197 ."/mnt/etc/os-release"."PRETTY_NAME": 'SUSE Linux Enterprise Server 12'
os_release = content.lines.grep(/os-release.*PRETTY_NAME":/).last
if os_release
product = os_release[/'(.*)'/, 1]
result[:product] = product
end
end

def analyze_log(result, file)
file = unpack_file(file)
# TODO: can be memory consuming
content = File.read(file)
find_modules(result, content)
find_base_product(result, content)
rescue ArgumentError => e
raise "Failed in #{file} with #{e.inspect}"
end
Expand Down Expand Up @@ -125,6 +136,13 @@ def merge_results(total, single)
total[:modules][m][:at_least_once] ||= 0
total[:modules][m][:at_least_once] += 1
end

total[:products] ||= {}
product = single[:product]
if product
total[:products][product] ||= 0
total[:products][product] += 1
end
end

logger = "/dev/null"
Expand Down

0 comments on commit 0a1d241

Please sign in to comment.