summaryrefslogtreecommitdiffstats
path: root/lib/puppet/reports/rrdgraph.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/reports/rrdgraph.rb')
-rw-r--r--lib/puppet/reports/rrdgraph.rb46
1 files changed, 25 insertions, 21 deletions
diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb
index 0fb7e2ea7..2c405c051 100644
--- a/lib/puppet/reports/rrdgraph.rb
+++ b/lib/puppet/reports/rrdgraph.rb
@@ -1,34 +1,38 @@
require 'puppet'
-Puppet::Server::Report.newreport(:rrdgraph) do |report|
- time = Time.now.to_i
+Puppet::Server::Report.newreport(:rrdgraph) do
+ desc "Graph some data about hosts."
- host = report.host
+ def process
+ time = Time.now.to_i
- hostdir = File.join(Puppet[:rrddir], host)
+ host = self.host
- unless File.directory?(hostdir)
- # Some hackishness to create the dir
- config = Puppet::Config.new
- config.setdefaults(:reports, :hostdir => [hostdir, "eh"])
+ hostdir = File.join(Puppet[:rrddir], host)
- # This creates the dir.
- config.use(:reports)
- end
+ unless File.directory?(hostdir)
+ # Some hackishness to create the dir
+ config = Puppet::Config.new
+ config.setdefaults(:reports, :hostdir => [hostdir, "eh"])
- File.open(File.join(hostdir, "index.html"),"w") { |of|
- of.puts "<html><body>"
- report.metrics.each do |name, metric|
- metric.basedir = hostdir
- metric.store(time)
+ # This creates the dir.
+ config.use(:reports)
+ end
- metric.graph
+ File.open(File.join(hostdir, "index.html"),"w") { |of|
+ of.puts "<html><body>"
+ self.metrics.each do |name, metric|
+ metric.basedir = hostdir
+ metric.store(time)
- of.puts "<img src=%s.png><br>" % name
- end
+ metric.graph
- of.puts "</body></html>"
- }
+ of.puts "<img src=%s.png><br>" % name
+ end
+
+ of.puts "</body></html>"
+ }
+ end
end
# $Id$