| Class | Puppet::Transaction::Report |
| In: |
lib/puppet/transaction/report.rb
|
| Parent: | Object |
A class for reporting what happens on each client. Reports consist of two types of data: Logs and Metrics. Logs are the output that each change produces, and Metrics are all of the numerical data involved in the transaction.
| host | [RW] | |
| logs | [RW] | |
| metrics | [RW] | |
| time | [RW] |
# File lib/puppet/transaction/report.rb, line 20
20: def initialize
21: @metrics = {}
22: @logs = []
23:
24: @records = Hash.new do |hash, key|
25: hash[key] = []
26: end
27:
28: @host = Puppet[:certname]
29: end
# File lib/puppet/transaction/report.rb, line 15
15: def <<(msg)
16: @logs << msg
17: return self
18: end
# File lib/puppet/transaction/report.rb, line 51
51: def record(metric, object)
52: @records[metric] << object
53: end
Provide a summary of this report.
# File lib/puppet/transaction/report.rb, line 56
56: def summary
57: ret = ""
58:
59: @metrics.sort { |a,b| a[1].label <=> b[1].label }.each do |name, metric|
60: ret += "%s:\n" % metric.label
61: metric.values.sort { |a,b|
62: # sort by label
63: if a[0] == :total
64: 1
65: elsif b[0] == :total
66: -1
67: else
68: a[1] <=> b[1]
69: end
70: }.each do |name, label, value|
71: next if value == 0
72: if value.is_a?(Float)
73: value = "%0.2f" % value
74: end
75: ret += " %15s %s\n" % [label + ":", value]
76: end
77: end
78: return ret
79: end