diff options
Diffstat (limited to 'lib/puppet/client')
-rw-r--r-- | lib/puppet/client/master.rb | 27 | ||||
-rw-r--r-- | lib/puppet/client/reporter.rb | 10 |
2 files changed, 35 insertions, 2 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb index 3f54fa27f..6d57a310a 100644 --- a/lib/puppet/client/master.rb +++ b/lib/puppet/client/master.rb @@ -19,6 +19,15 @@ class Puppet::Client::MasterClient < Puppet::Client ] ) + Puppet.setdefaults(:puppetd, + :reportserver => ["puppet", + "The server to which to send transaction reports." + ], + :report => [false, + "Whether to send reports after every transaction." + ] + ) + Puppet.setdefaults("puppet", :pluginpath => ["$vardir/plugins", "Where Puppet should look for plugins. Multiple directories should @@ -102,6 +111,14 @@ class Puppet::Client::MasterClient < Puppet::Client Metric.graph end + if Puppet[:report] + begin + reportclient().report(transaction) + rescue => detail + Puppet.err "Reporting failed: %s" % detail + end + end + return transaction end @@ -480,6 +497,16 @@ class Puppet::Client::MasterClient < Puppet::Client # Now clean up after ourselves plugins.remove end + + def reportclient + unless defined? @reportclient + @reportclient = Puppet::Client::Reporter.new( + :Server => Puppet[:reportserver] + ) + end + + @reportclient + end end # $Id$ diff --git a/lib/puppet/client/reporter.rb b/lib/puppet/client/reporter.rb index c4f6acd0c..ff80f367d 100644 --- a/lib/puppet/client/reporter.rb +++ b/lib/puppet/client/reporter.rb @@ -13,10 +13,14 @@ class Puppet::Client::Reporter < Puppet::Client::ProxyClient super(hash) end - def report(array) + # Send our report. We get the transaction, and we convert it to a report + # as appropriate. + def report(transaction) # We receive an array of log events, and we need to convert them into # a single big YAML file. + array = transaction.report + report = YAML.dump(array) unless self.local @@ -24,7 +28,9 @@ class Puppet::Client::Reporter < Puppet::Client::ProxyClient end # Now send the report - file = @driver.report(report) + benchmark(:info, "Sent transaction report") do + file = @driver.report(report) + end end end |