summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-10-04 15:37:19 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-10-04 15:37:23 -0700
commit6acfdba87bdffe4afd6e00cbf3695160f7994357 (patch)
tree30d09c8a40073f6d9fa95c8bef0d4a18b462c348
parent1a00c07971c4297bce1b3e0edee3b6b3399e17bb (diff)
parent6dd1930ff66f6e89ff3d7edba9cc20126d9cd9a3 (diff)
downloadpuppet-6acfdba87bdffe4afd6e00cbf3695160f7994357.tar.gz
puppet-6acfdba87bdffe4afd6e00cbf3695160f7994357.tar.xz
puppet-6acfdba87bdffe4afd6e00cbf3695160f7994357.zip
Partial merge to 2.6.2rc1 : Merge commits 'd057b90' and '6dd1930' into next
This commit merges in d057b90 with the addition of commit 6dd1930 to fix some tests that are confined to machines where rrd is installed.
-rw-r--r--lib/puppet/defaults.rb11
-rw-r--r--lib/puppet/feature/base.rb3
-rw-r--r--lib/puppet/util/metric.rb47
-rwxr-xr-xtest/other/report.rb7
-rwxr-xr-xtest/util/metrics.rb4
5 files changed, 51 insertions, 21 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 972e9e66c..ab127602b 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -453,6 +453,12 @@ module Puppet
:reporturl => ["http://localhost:3000/reports",
"The URL used by the http reports processor to send reports"],
:fileserverconfig => ["$confdir/fileserver.conf", "Where the fileserver configuration is stored."],
+ :strict_hostname_checking => [false, "Whether to only search for the complete
+ hostname as it is in the certificate when searching for node information
+ in the catalogs."]
+ )
+
+ setdefaults(:metrics,
:rrddir => {:default => "$vardir/rrd",
:owner => "service",
:group => "service",
@@ -461,10 +467,7 @@ module Puppet
this directory."
},
:rrdinterval => ["$runinterval", "How often RRD should expect data.
- This should match how often the hosts report back to the server."],
- :strict_hostname_checking => [false, "Whether to only search for the complete
- hostname as it is in the certificate when searching for node information
- in the catalogs."]
+ This should match how often the hosts report back to the server."]
)
setdefaults(:agent,
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb
index c153fba98..c983f5c12 100644
--- a/lib/puppet/feature/base.rb
+++ b/lib/puppet/feature/base.rb
@@ -27,7 +27,8 @@ Puppet.features.add :diff, :libs => %w{diff/lcs diff/lcs/hunk}
Puppet.features.add(:augeas, :libs => ["augeas"])
# We have RRD available
-Puppet.features.add(:rrd, :libs => ["RRDtool"])
+Puppet.features.add(:rrd_legacy, :libs => ["RRDtool"])
+Puppet.features.add(:rrd, :libs => ["RRD"])
# We have OpenSSL
Puppet.features.add(:openssl, :libs => ["openssl"])
diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb
index 7e14a5fec..00898472f 100644
--- a/lib/puppet/util/metric.rb
+++ b/lib/puppet/util/metric.rb
@@ -31,9 +31,12 @@ class Puppet::Util::Metric
start ||= Time.now.to_i - 5
- @rrd = RRDtool.new(self.path)
args = []
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ @rrd = RRDtool.new(self.path)
+ end
+
values.each { |value|
# the 7200 is the heartbeat -- this means that any data that isn't
# more frequently than every two hours gets thrown away
@@ -42,14 +45,22 @@ class Puppet::Util::Metric
args.push "RRA:AVERAGE:0.5:1:300"
begin
- @rrd.create( Puppet[:rrdinterval].to_i, start, args)
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ @rrd.create( Puppet[:rrdinterval].to_i, start, args)
+ else
+ RRD.create( self.path, '-s', Puppet[:rrdinterval].to_i.to_s, '-b', start.to_i.to_s, *args)
+ end
rescue => detail
raise "Could not create RRD file #{path}: #{detail}"
end
end
def dump
- puts @rrd.info
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ puts @rrd.info
+ else
+ puts RRD.info self.path
+ end
end
def graph(range = nil)
@@ -82,14 +93,26 @@ class Puppet::Util::Metric
args << lines
args.flatten!
if range
- args.push("--start",range[0],"--end",range[1])
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ args.push("--start",range[0],"--end",range[1])
+ else
+ args.push("--start",range[0].to_i.to_s,"--end",range[1].to_i.to_s)
+ end
else
- args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
+ else
+ args.push("--start", (Time.now.to_i - time).to_s, "--end", Time.now.to_i.to_s)
+ end
end
begin
#Puppet.warning "args = #{args}"
- RRDtool.graph( args )
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ RRDtool.graph( args )
+ else
+ RRD.graph( *args )
+ end
rescue => detail
Puppet.err "Failed to graph #{self.name}: #{detail}"
end
@@ -114,13 +137,15 @@ class Puppet::Util::Metric
end
def store(time)
- unless Puppet.features.rrd?
+ unless Puppet.features.rrd? || Puppet.features.rrd_legacy?
Puppet.warning "RRD library is missing; cannot store metrics"
return
end
self.create(time - 5) unless FileTest.exists?(self.path)
- @rrd ||= RRDtool.new(self.path)
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ @rrd ||= RRDtool.new(self.path)
+ end
# XXX this is not terribly error-resistant
args = [time]
@@ -133,7 +158,11 @@ class Puppet::Util::Metric
arg = args.join(":")
template = temps.join(":")
begin
- @rrd.update( template, [ arg ] )
+ if Puppet.features.rrd_legacy? && ! Puppet.features.rrd?
+ @rrd.update( template, [ arg ] )
+ else
+ RRD.update( self.path, '-t', template, arg )
+ end
#system("rrdtool updatev #{self.path} '#{arg}'")
rescue => detail
raise Puppet::Error, "Failed to update #{self.name}: #{detail}"
diff --git a/test/other/report.rb b/test/other/report.rb
index b3b41da19..8a909b41c 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -35,10 +35,7 @@ class TestReports < Test::Unit::TestCase
config.retrieval_duration = 0.001
trans = config.apply
- report = Puppet::Transaction::Report.new
- trans.add_metrics_to_report(report)
-
- report
+ trans.generate_report
end
# Make sure we can use reports as log destinations.
@@ -95,7 +92,7 @@ class TestReports < Test::Unit::TestCase
assert_equal(yaml, File.read(file), "File did not get written")
end
- if Puppet.features.rrd?
+ if Puppet.features.rrd? || Puppet.features.rrd_legacy?
def test_rrdgraph_report
Puppet.settings.use(:main, :metrics)
report = mkreport
diff --git a/test/util/metrics.rb b/test/util/metrics.rb
index 1fd57f2f1..82e792d0b 100755
--- a/test/util/metrics.rb
+++ b/test/util/metrics.rb
@@ -8,7 +8,7 @@ require 'puppettest'
require 'puppet/type'
class TestMetric < PuppetTest::TestCase
- confine "Missing RRDtool library" => Puppet.features.rrd?
+ confine "Missing RRDtool library" => (Puppet.features.rrd? || Puppet.features.rrd_legacy?)
include PuppetTest
def gendata
@@ -43,7 +43,7 @@ class TestMetric < PuppetTest::TestCase
def rundata(report, time)
assert_nothing_raised {
gendata.each do |name, data|
- report.newmetric(name, data)
+ report.add_metric(name, data)
end
report.metrics.each { |n, m| m.store(time) }
}