~ubuntu-branches/ubuntu/wily/puppet/wily

« back to all changes in this revision

Viewing changes to lib/puppet/util/metric.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-04-17 14:50:28 UTC
  • mfrom: (3.1.59 sid)
  • Revision ID: package-import@ubuntu.com-20140417145028-j3p3dwvp8ggpzvaf
Tags: 3.5.1-1
ImportedĀ upstreamĀ releaseĀ 3.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
  attr_writer :basedir
13
13
 
14
 
  def self.from_pson(data)
 
14
  def self.from_data_hash(data)
15
15
    metric = new(data['name'], data['label'])
16
16
    metric.values = data['values']
17
17
    metric
18
18
  end
19
19
 
 
20
  def self.from_pson(data)
 
21
    Puppet.deprecation_warning("from_pson is being removed in favour of from_data_hash.")
 
22
    self.from_data_hash(data)
 
23
  end
 
24
 
20
25
  def to_data_hash
21
26
    {
22
27
      'name' => @name,
71
76
        RRD.create( self.path, '-s', Puppet[:rrdinterval].to_s, '-b', start.to_i.to_s, *args)
72
77
      end
73
78
    rescue => detail
74
 
      raise "Could not create RRD file #{path}: #{detail}"
 
79
      raise detail, "Could not create RRD file #{path}: #{detail}", detail.backtrace
75
80
    end
76
81
  end
77
82
 
161
166
      Puppet.warning "RRD library is missing; cannot store metrics"
162
167
      return
163
168
    end
164
 
    self.create(time - 5) unless Puppet::FileSystem::File.exist?(self.path)
 
169
    self.create(time - 5) unless Puppet::FileSystem.exist?(self.path)
165
170
 
166
171
    if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
167
172
      @rrd ||= RRDtool.new(self.path)
185
190
      end
186
191
      #system("rrdtool updatev #{self.path} '#{arg}'")
187
192
    rescue => detail
188
 
      raise Puppet::Error, "Failed to update #{self.name}: #{detail}"
 
193
      raise Puppet::Error, "Failed to update #{self.name}: #{detail}", detail.backtrace
189
194
    end
190
195
  end
191
196