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