Gentoo Archives: gentoo-commits

From: "Matsuu Takuto (matsuu)" <matsuu@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/puppet/files: puppet-0.25.4-rrd.patch
Date: Sun, 28 Feb 2010 03:04:59
Message-Id: E1NlZSj-0003dM-46@stork.gentoo.org
1 matsuu 10/02/28 03:04:57
2
3 Added: puppet-0.25.4-rrd.patch
4 Log:
5 Version bumped. Fixed rrd issue, bug #294304.
6 (Portage version: 2.1.7.17/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 app-admin/puppet/files/puppet-0.25.4-rrd.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/puppet/files/puppet-0.25.4-rrd.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/puppet/files/puppet-0.25.4-rrd.patch?rev=1.1&content-type=text/plain
13
14 Index: puppet-0.25.4-rrd.patch
15 ===================================================================
16 diff -Naur puppet-0.25.4.orig//lib/puppet/feature/base.rb puppet-0.25.4//lib/puppet/feature/base.rb
17 --- puppet-0.25.4.orig//lib/puppet/feature/base.rb 2010-01-28 12:48:33.000000000 +0900
18 +++ puppet-0.25.4//lib/puppet/feature/base.rb 2010-02-28 11:36:28.000000000 +0900
19 @@ -27,7 +27,7 @@
20 Puppet.features.add(:augeas, :libs => ["augeas"])
21
22 # We have RRD available
23 -Puppet.features.add(:rrd, :libs => ["RRDtool"])
24 +Puppet.features.add(:rrd, :libs => ["RRD"])
25
26 # We have OpenSSL
27 Puppet.features.add(:openssl, :libs => ["openssl"])
28 diff -Naur puppet-0.25.4.orig//lib/puppet/reports/rrdgraph.rb puppet-0.25.4//lib/puppet/reports/rrdgraph.rb
29 --- puppet-0.25.4.orig//lib/puppet/reports/rrdgraph.rb 2010-01-28 12:48:34.000000000 +0900
30 +++ puppet-0.25.4//lib/puppet/reports/rrdgraph.rb 2010-02-28 11:35:34.000000000 +0900
31 @@ -1,12 +1,13 @@
32 Puppet::Reports.register_report(:rrdgraph) do
33 desc "Graph all available data about hosts using the RRD library. You
34 must have the Ruby RRDtool library installed to use this report, which
35 - you can get from `the RubyRRDTool RubyForge page`_. This package may also
36 - be available as ``ruby-rrd`` or ``rrdtool-ruby`` in your distribution's package
37 + is bundled in RRDtool, which you can get from `the RRDTool homepage`_.
38 + This package may also be available as ``librrd-ruby``, ``ruby-rrd`` or
39 + ``rrdtool-ruby`` in your distribution's package
40 management system. The library and/or package will both require the binary
41 ``rrdtool`` package from your distribution to be installed.
42
43 - .. _the RubyRRDTool RubyForge page: http://rubyforge.org/projects/rubyrrdtool/
44 + .. _the RRDTool homepage: http://oss.oetiker.ch/rrdtool/download.en.html
45
46 This report will create, manage, and graph RRD database files for each
47 of the metrics generated during transactions, and it will create a
48 diff -Naur puppet-0.25.4.orig//lib/puppet/util/metric.rb puppet-0.25.4//lib/puppet/util/metric.rb
49 --- puppet-0.25.4.orig//lib/puppet/util/metric.rb 2010-01-28 12:48:34.000000000 +0900
50 +++ puppet-0.25.4//lib/puppet/util/metric.rb 2010-02-28 11:35:34.000000000 +0900
51 @@ -1,5 +1,6 @@
52 # included so we can test object types
53 require 'puppet'
54 +require 'RRD'
55
56 # A class for handling metrics. This is currently ridiculously hackish.
57 class Puppet::Util::Metric
58 @@ -31,7 +32,6 @@
59
60 start ||= Time.now.to_i - 5
61
62 - @rrd = RRDtool.new(self.path)
63 args = []
64
65 values.each { |value|
66 @@ -42,14 +42,17 @@
67 args.push "RRA:AVERAGE:0.5:1:300"
68
69 begin
70 - @rrd.create( Puppet[:rrdinterval].to_i, start, args)
71 + RRD.create(self.path,
72 + "--start", start.to_s,
73 + "--step", Puppet[:rrdinterval].to_i,
74 + *args)
75 rescue => detail
76 raise "Could not create RRD file %s: %s" % [path,detail]
77 end
78 end
79
80 def dump
81 - puts @rrd.info
82 + puts RRD.info(self.path)
83 end
84
85 def graph(range = nil)
86 @@ -84,12 +87,12 @@
87 if range
88 args.push("--start",range[0],"--end",range[1])
89 else
90 - args.push("--start", Time.now.to_i - time, "--end", Time.now.to_i)
91 + args.push("--start", (Time.now.to_i - time).to_s, "--end", Time.now.to_i.to_s)
92 end
93
94 begin
95 - #Puppet.warning "args = #{args}"
96 - RRDtool.graph( args )
97 + #Puppet.warning "args = #{args.join("|")}"
98 + RRD.graph( * args )
99 rescue => detail
100 Puppet.err "Failed to graph %s: %s" % [self.name,detail]
101 end
102 @@ -122,7 +125,6 @@
103 self.create(time - 5)
104 end
105
106 - @rrd ||= RRDtool.new(self.path)
107
108 # XXX this is not terribly error-resistant
109 args = [time]
110 @@ -135,7 +137,9 @@
111 arg = args.join(":")
112 template = temps.join(":")
113 begin
114 - @rrd.update( template, [ arg ] )
115 + RRD.update(self.path,
116 + "--template", template,
117 + arg )
118 #system("rrdtool updatev %s '%s'" % [self.path, arg])
119 rescue => detail
120 raise Puppet::Error, "Failed to update %s: %s" % [self.name,detail]
121 diff -Naur puppet-0.25.4.orig//spec/unit/util/metric.rb puppet-0.25.4//spec/unit/util/metric.rb
122 --- puppet-0.25.4.orig//spec/unit/util/metric.rb 2010-01-28 12:48:34.000000000 +0900
123 +++ puppet-0.25.4//spec/unit/util/metric.rb 2010-02-28 11:35:34.000000000 +0900
124 @@ -7,6 +7,13 @@
125 describe Puppet::Util::Metric do
126 before do
127 @metric = Puppet::Util::Metric.new("foo")
128 + #if we don't retrive it before the test the :rrddir test will
129 + #fail at after
130 + @basedir = @metric.basedir
131 + end
132 +
133 + after do
134 + FileUtils.rm_rf(@basedir) if File.directory?(@basedir)
135 end
136
137 it "should be aliased to Puppet::Metric" do
138 @@ -84,12 +91,46 @@
139 @metric[:foo].should be_nil
140 end
141
142 - # LAK: I'm not taking the time to develop these tests right now.
143 - # I expect they should actually be extracted into a separate class
144 - # anyway.
145 - it "should be able to graph metrics using RRDTool"
146 -
147 - it "should be able to create a new RRDTool database"
148 -
149 - it "should be able to store metrics into an RRDTool database"
150 + it "should be able to graph metrics using RRDTool" do
151 + ensure_rrd_folder
152 + populate_metric
153 + @metric.graph
154 + end
155 +
156 + it "should be able to create a new RRDTool database" do
157 + ensure_rrd_folder
158 + add_random_values_to_metric
159 + @metric.create
160 + File.exist?(@metric.path).should == true
161 + end
162 +
163 + it "should be able to store metrics into an RRDTool database" do
164 + ensure_rrd_folder
165 + populate_metric
166 + File.exist?(@metric.path).should == true
167 + end
168 +
169 + def ensure_rrd_folder()
170 + #in normal runs puppet does this for us (not sure where)
171 + FileUtils.mkdir_p(@basedir) unless File.directory?(@basedir)
172 + end
173 +
174 + def populate_metric()
175 + time = Time.now.to_i
176 + time -= 100 * 1800
177 + 200.times {
178 + @metric = Puppet::Util::Metric.new("foo")
179 + add_random_values_to_metric
180 + @metric.store(time)
181 + time += 1800
182 + }
183 + end
184 +
185 + def add_random_values_to_metric()
186 + @metric.values.clear
187 + random_params = { :data1 => 10, :data2 => 30, :data3 => 100 }
188 + random_params.each { | label, maxvalue |
189 + @metric.newvalue(label, rand(maxvalue))
190 + }
191 + end
192 end
193 diff -Naur puppet-0.25.4.orig//test/util/metrics.rb puppet-0.25.4//test/util/metrics.rb
194 --- puppet-0.25.4.orig//test/util/metrics.rb 2010-01-28 12:48:34.000000000 +0900
195 +++ puppet-0.25.4//test/util/metrics.rb 2010-02-28 11:35:34.000000000 +0900
196 @@ -53,6 +53,8 @@
197 report = Puppet::Transaction::Report.new
198 time = Time.now.to_i
199 start = time
200 + #in normal runs puppet does this for us (not sure where)
201 + Dir.mkdir(Puppet[:rrddir]) unless File.directory?(Puppet[:rrddir])
202 10.times {
203 rundata(report, time)
204 time += 300