2 # $Id: test.rb,v 1.2 2002/10/22 17:34:00 miles Exp $
3 # Driver does not carry cash.
5 $: << '/scratch/rrd12build/lib/ruby/1.8/i386-linux/'
13 puts "creating #{rrd}"
16 "--start", "#{start - 1}",
20 "RRA:AVERAGE:0.5:1:300")
23 puts "updating #{rrd}"
24 start.to_i.step(start.to_i + 300 * 300, 300) { |i|
25 RRD.update(rrd, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}")
29 puts "fetching data from #{rrd}"
30 (fstart, fend, data) = RRD.fetch(rrd, "--start", start.to_s, "--end", (start + 300 * 300).to_s, "AVERAGE")
31 puts "got #{data.length} data points from #{fstart} to #{fend}"
34 puts "generating graph #{name}.png"
37 "--title", " RubyRRD Demo",
38 "--start", "#{start+3600}",
39 "--end", "start + 1000 min",
43 "DEF:a=#{rrd}:a:AVERAGE",
44 "DEF:b=#{rrd}:b:AVERAGE",
45 "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
47 "AREA:line#0022e9:alpha",
51 print "This script has created #{name}.png in the current directory\n";
52 print "This demonstrates the use of the TIME and % RPN operators\n";