140: def store(time)
141: unless Puppet.features.rrd? || Puppet.features.rrd_legacy?
142: Puppet.warning "RRD library is missing; cannot store metrics"
143: return
144: end
145: self.create(time - 5) unless FileTest.exists?(self.path)
146:
147: if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
148: @rrd ||= RRDtool.new(self.path)
149: end
150:
151:
152: args = [time]
153: temps = []
154: values.each { |value|
155:
156: args.push value[2]
157: temps.push value[0]
158: }
159: arg = args.join(":")
160: template = temps.join(":")
161: begin
162: if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
163: @rrd.update( template, [ arg ] )
164: else
165: RRD.update( self.path, '-t', template, arg )
166: end
167:
168: rescue => detail
169: raise Puppet::Error, "Failed to update #{self.name}: #{detail}"
170: end
171: end