M
Mark Probert
Hi ..
I am pleased to announce the initial release of rubyrrdtool, a Ruby
extension supporting RRDtool 1.2.x.
The release can be found at RubyForge (thanks, Tom):
http://rubyforge.org/projects/rubyrrdtool/
This release (0.5.0) should be considered alpha. Documentation is
scarce, though I have added RDoc code into the extension. The extension
works, though it is missing a nice class wrapper and a definitive test
suite. A beta version should be out in the next few weeks.
This project is an update on earlier work done by Miles Egan, and
extends and enhances the code to support all of the RRDtool extended
commands, such as rrd_fetch(), rrd_xport() and rrd_info(). Internally,
it makes use of the newer thread-safe calls included in libRRDtool.
There are a number of examples to be found in the play/ directory.
As a warning, I haven't tested any of this code against a 1.1 release of
RRDtool. My guss is that it will fail dismally as it uses the
thread-safe versions of the function calls whenever it can. I believe
that these are only in 1.2+. For earlier releases, using Miles original
interface code would be my suggested work-around.
As a sampler, the minmax example in Ruby looks like
#!/usr/bin/env ruby
require "RRDtool"
name = "minmax"
rrdname = "#{name}.rrd"
start = Time.now.to_i
rrd = RRDtool.new(rrdname)
puts "created new RRD database -> #{rrd.rrdname}"
puts "RRDTool library vers -> #{rrd.version}"
# ---------------------------------------------
# Create
# ---------------------------------------------
puts " .. creating #{rrdname}"
n = rrd.create(
300, start-1,
["DS:ds_0:GAUGE:600:U:U",
"RRA:AVERAGE:0.5:1:300",
"RRA:MIN:0.5:12:300",
"RRA:MAX:0.5:12:300"])
# ---------------------------------------------
# Update
# ---------------------------------------------
puts " .. updating #{rrdname}"
val = start.to_i
while (val < (start.to_i+300*300)) do
rrd.update("ds_0", ["#{val}:#{Math.sin(val / 3000) * 50 + 50}"])
val += 300
end
# ---------------------------------------------
# Graph
# ---------------------------------------------
puts "generating graph #{name}.png"
rrd.graph(
["#{name}.png",
"DEF:a=#{rrdname}:ds_0:AVERAGE",
"DEF:b=#{rrdname}:ds_0:MIN",
"DEF:c=#{rrdname}:ds_0:MAX",
"--title", " #{name} Demo",
"--start", "now",
"--end", "start+1d",
"--lower-limit=0",
"--interlace",
"--imgformat", "PNG",
"--width=450",
"AREA:a#00b6e4:real",
"LINE1:b#0022e9:min",
"LINE1:c#000000:max"])
Regards,
I am pleased to announce the initial release of rubyrrdtool, a Ruby
extension supporting RRDtool 1.2.x.
The release can be found at RubyForge (thanks, Tom):
http://rubyforge.org/projects/rubyrrdtool/
This release (0.5.0) should be considered alpha. Documentation is
scarce, though I have added RDoc code into the extension. The extension
works, though it is missing a nice class wrapper and a definitive test
suite. A beta version should be out in the next few weeks.
This project is an update on earlier work done by Miles Egan, and
extends and enhances the code to support all of the RRDtool extended
commands, such as rrd_fetch(), rrd_xport() and rrd_info(). Internally,
it makes use of the newer thread-safe calls included in libRRDtool.
There are a number of examples to be found in the play/ directory.
As a warning, I haven't tested any of this code against a 1.1 release of
RRDtool. My guss is that it will fail dismally as it uses the
thread-safe versions of the function calls whenever it can. I believe
that these are only in 1.2+. For earlier releases, using Miles original
interface code would be my suggested work-around.
As a sampler, the minmax example in Ruby looks like
#!/usr/bin/env ruby
require "RRDtool"
name = "minmax"
rrdname = "#{name}.rrd"
start = Time.now.to_i
rrd = RRDtool.new(rrdname)
puts "created new RRD database -> #{rrd.rrdname}"
puts "RRDTool library vers -> #{rrd.version}"
# ---------------------------------------------
# Create
# ---------------------------------------------
puts " .. creating #{rrdname}"
n = rrd.create(
300, start-1,
["DS:ds_0:GAUGE:600:U:U",
"RRA:AVERAGE:0.5:1:300",
"RRA:MIN:0.5:12:300",
"RRA:MAX:0.5:12:300"])
# ---------------------------------------------
# Update
# ---------------------------------------------
puts " .. updating #{rrdname}"
val = start.to_i
while (val < (start.to_i+300*300)) do
rrd.update("ds_0", ["#{val}:#{Math.sin(val / 3000) * 50 + 50}"])
val += 300
end
# ---------------------------------------------
# Graph
# ---------------------------------------------
puts "generating graph #{name}.png"
rrd.graph(
["#{name}.png",
"DEF:a=#{rrdname}:ds_0:AVERAGE",
"DEF:b=#{rrdname}:ds_0:MIN",
"DEF:c=#{rrdname}:ds_0:MAX",
"--title", " #{name} Demo",
"--start", "now",
"--end", "start+1d",
"--lower-limit=0",
"--interlace",
"--imgformat", "PNG",
"--width=450",
"AREA:a#00b6e4:real",
"LINE1:b#0022e9:min",
"LINE1:c#000000:max"])
Regards,