1 =head1 NAME
3 rrdruby - About the RRD Ruby bindings
5 =head1 SYNOPSIS
7 require "RRD"
8 RRD.create(
9 rrd,
10 "--step", "300",
11 "DS:a:GAUGE:600:U:U",
12 "DS:b:GAUGE:600:U:U",
13 "RRA:AVERAGE:0.5:1:300")
15 =head1 DESCRIPTION
17 The B<rrdtool> functions are directly callable via the Ruby programming
18 language. This wrapper implementation has been written from the scratch
19 (without SWIG)
21 The API's simply expects string parameters to the functions. Please refer
22 to the other B<rrdtool> documentation for functions and valid arguments.
24 =head1 EXAMPLE
26 $: << '/path/to/rrdtool/lib/ruby/1.8/i386-linux'
27 require "RRD"
29 name = "test"
30 rrd = "#{name}.rrd"
31 start = Time.now.to_i
33 RRD.create(
34 rrd,
35 "--start", "#{start - 1}",
36 "--step", "300",
37 "DS:a:GAUGE:600:U:U",
38 "DS:b:GAUGE:600:U:U",
39 "RRA:AVERAGE:0.5:1:300")
40 puts
42 puts "updating #{rrd}"
43 start.to_i.step(start.to_i + 300 * 300, 300) { |i|
44 RRD.update(rrd, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}")
45 }
46 puts
48 puts "fetching data from #{rrd}"
49 (fstart, fend, data, step) = RRD.fetch(rrd, "--start", start.to_s, "--end",
50 (start + 300 * 300).to_s, "AVERAGE")
51 puts "got #{data.length} data points from #{fstart} to #{fend}"
52 puts
54 puts "generating graph #{name}.png"
55 RRD.graph(
56 "#{name}.png",
57 "--title", " RubyRRD Demo",
58 "--start", "#{start+3600}",
59 "--end", "start + 1000 min",
60 "--interlace",
61 "--imgformat", "PNG",
62 "--width=450",
63 "DEF:a=#{rrd}:a:AVERAGE",
64 "DEF:b=#{rrd}:b:AVERAGE",
65 "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
66 "AREA:b#00b6e4:beta",
67 "AREA:line#0022e9:alpha",
68 "LINE3:line#ff0000")
69 puts
71 If you use the B<--ruby-site-install> configure option you can drop the $:
72 line since the rrdtool module will be found automatically.
74 If rrdtool runs into trouble, it will throw an exception which you might
75 want to catch.
77 =head1 SEE ALSO
79 rrdcreate, rrdupdate, rrdgraph, rrddump, rrdfetch, rrdtune, rrdlast,
80 rrdxport, rrdinfo
82 =head1 AUTHOR
84 Loïs Lherbier E<lt>lois.lherbier@covadis.chE<gt>
86 Miles Egan E<lt>miles@caddr.comE<gt>