The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

puppet-rrdtool-interface.patch

Davor Ocelic, 09/04/2010 03:39 pm

Download (2.7 KB)

View differences:

lib/puppet/feature/base.rb
27 27
Puppet.features.add(:augeas, :libs => ["augeas"])
28 28

  
29 29
# We have RRD available
30
Puppet.features.add(:rrd, :libs => ["RRDtool"])
30
Puppet.features.add(:rrd, :libs => ["RRD"])
31 31

  
32 32
# We have OpenSSL
33 33
Puppet.features.add(:openssl, :libs => ["openssl"])
lib/puppet/util/metric.rb
31 31

  
32 32
    start ||= Time.now.to_i - 5
33 33

  
34
    @rrd = RRDtool.new(self.path)
35 34
    args = []
36 35

  
37 36
    values.each { |value|
......
42 41
    args.push "RRA:AVERAGE:0.5:1:300"
43 42

  
44 43
    begin
45
      @rrd.create( Puppet[:rrdinterval].to_i, start, args)
44
      RRD.create( self.path, '-s', Puppet[:rrdinterval].to_i.to_s, '-b', start.to_i.to_s, *args)
46 45
    rescue => detail
47 46
      raise "Could not create RRD file #{path}: #{detail}"
48 47
    end
49 48
  end
50 49

  
51 50
  def dump
52
    puts @rrd.info
51
    puts RRD.info self.path
53 52
  end
54 53

  
55 54
  def graph(range = nil)
......
82 81
      args << lines
83 82
      args.flatten!
84 83
      if range
85
        args.push("--start",range[0],"--end",range[1])
84
        args.push("--start",range[0].to_i.to_s,"--end",range[1].to_i.to_s)
86 85
      else
87
        args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
86
        args.push("--start", (Time.now.to_i - time).to_s, "--end", Time.now.to_i.to_s)
88 87
      end
89 88

  
90 89
      begin
91 90
        #Puppet.warning "args = #{args}"
92
        RRDtool.graph( args )
91
        RRD.graph( *args )
93 92
      rescue => detail
94 93
        Puppet.err "Failed to graph #{self.name}: #{detail}"
95 94
      end
......
120 119
    end
121 120
    self.create(time - 5) unless FileTest.exists?(self.path)
122 121

  
123
    @rrd ||= RRDtool.new(self.path)
124

  
125 122
    # XXX this is not terribly error-resistant
126 123
    args = [time]
127 124
    temps = []
......
133 130
    arg = args.join(":")
134 131
    template = temps.join(":")
135 132
    begin
136
      @rrd.update( template, [ arg ] )
133
      RRD.update( self.path, '-t', template, arg )
137 134
      #system("rrdtool updatev #{self.path} '#{arg}'")
138 135
    rescue => detail
139 136
      raise Puppet::Error, "Failed to update #{self.name}: #{detail}"