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