blob: ad6b82a8a29ac8d5afd9833ca5ae733b8f156e65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
require 'puppet'
# 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.
class Puppet::Transaction::Report
attr_accessor :logs, :metrics, :time, :host
def <<(msg)
@logs << msg
return self
end
def initialize
@metrics = {}
@logs = []
@records = Hash.new do |hash, key|
hash[key] = []
end
domain = Facter.value("domain")
hostname = Facter.value("hostname")
if !domain || domain.empty? then
@host = hostname
else
@host = [hostname, domain].join(".")
end
end
# Create a new metric.
def newmetric(name, hash)
metric = Puppet::Util::Metric.new(name)
hash.each do |name, value|
metric.newvalue(name, value)
end
@metrics[metric.name] = metric
end
# Add a new log message.
def newlog(msg)
@logs << msg
end
def record(metric, object)
@records[metric] << object
end
end
# $Id$
|