Skip to content

Instantly share code, notes, and snippets.

@bodepd
Created July 7, 2015 22:21
Show Gist options
  • Save bodepd/d9c0b013db18e930393f to your computer and use it in GitHub Desktop.
Save bodepd/d9c0b013db18e930393f to your computer and use it in GitHub Desktop.
def parse_report(report_obj)
report = {}
report['start_time'] = report_obj.time
report['status'] = report_obj.status
report['configuration_version'] = report_obj.configuration_version
report['metrics'] = {}
report['resources'] = {}
report_obj.metrics['time'].values.each do |x|
if x[0] == 'total'
report['total_time'] = x[2]
end
end
if report['status'] == 'failed'
end
report
end
def organize_reports(report_objs)
reports = {}
report_objs.each do |x|
reports[x['configuration_version']] ||= {}
reports[x['configuration_version']][x['start_time']] = x
end
reports
end
def print_single_report(reports, key)
times = reports[key].keys.sort
times.each do |t|
report = reports[key][t]
puts " Started at #{t}, took #{report['total_time']}, result #{report['status']}"
end
end
def print_organized_reports(reports)
special_keys = ['settings', 'packages', 'bootstrap']
special_keys.each do |k|
puts "For run type: #{k}"
if reports[k].size != 1
puts "Expected 1 run, found #{reports[k].size}"
end
print_single_report(reports, k)
end
# None should not exist?
if reports['None']
puts "Unexpected run type: None"
print_single_report(reports, 'None')
end
versions = reports.keys - special_keys - ['None']
versions.each do |x|
puts "Found #{reports[x].size} report(s) for version #{x}"
print_single_report(reports, x)
end
end
if @options[:report_type] == 'dans_type'
rep_dir = '/var/lib/puppet/reports/'
reports = []
for file in Dir.glob("#{rep_dir}/*/*")
report = parse_report(load_report(file))
reports.push(report)
end
print_organized_reports(organize_reports(reports))
elsif
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment