# File lib/puppet/util/metric.rb, line 55
55:     def graph(range = nil)
56:         unless Puppet.features.rrd?
57:             Puppet.warning "RRD library is missing; cannot graph metrics"
58:             return
59:         end
60: 
61:         unit = 60 * 60 * 24
62:         colorstack = %w{#00ff00 #ff0000 #0000ff #ffff00 #ff99ff #ff9966 #66ffff #990000 #099000 #000990 #f00990 #0f0f0f #555555 #333333 #ffffff}
63: 
64:         {:daily => unit, :weekly => unit * 7, :monthly => unit * 30, :yearly => unit * 365}.each do |name, time|
65:             file = self.path.sub(/\.rrd$/, "-%s.png" % name)
66:             args = [file]
67: 
68:             args.push("--title",self.label)
69:             args.push("--imgformat","PNG")
70:             args.push("--interlace")
71:             i = 0
72:             defs = []
73:             lines = []
74:             #p @values.collect { |s,l| s }
75:             values.zip(colorstack).each { |value,color|
76:                 next if value.nil?
77:                 # this actually uses the data label
78:                 defs.push("DEF:%s=%s:%s:AVERAGE" % [value[0],self.path,value[0]])
79:                 lines.push("LINE2:%s%s:%s" % [value[0],color,value[1]])
80:             }
81:             args << defs
82:             args << lines
83:             args.flatten!
84:             if range
85:                 args.push("--start",range[0],"--end",range[1])
86:             else
87:                 args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
88:             end
89: 
90:             begin
91:                 #Puppet.warning "args = #{args}"
92:                 RRDtool.graph( args )
93:             rescue => detail
94:                 Puppet.err "Failed to graph %s: %s" % [self.name,detail]
95:             end
96:         end
97:     end