Attached a patch for the rrd-tool LIBDBI integration with the following improvements:
[rrdtool.git] / examples / bigtops.pl.in
1 #! @PERL@
2 # this is for after install
3 use lib qw( @prefix@/lib/perl );
4
5 use RRDs;
6 my $start=time;
7 my $rrd="randome.rrd";
8 my $name = $0;
9 $name =~ s/.*\///g;
10 $name =~ s/\.pl.*//g;
11
12 RRDs::create ($rrd, "--start",$start-1, "--step",300,
13               "DS:a:GAUGE:600:U:U",
14               "DS:b:GAUGE:600:U:U",
15               "RRA:AVERAGE:0.5:1:300");
16 my $ERROR = RRDs::error;
17 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
18
19 # dropt some data into the rrd
20 my $t;
21 for ($t=$start; $t<$start+300*300; $t+=300){
22   RRDs::update $rrd, "$t:".rand(100).":".(sin($t/800)*50+50);
23   if ($ERROR = RRDs::error) {
24     die "$0: unable to update `$rrd': $ERROR\n";
25   }
26 }
27
28 RRDs::graph "$name.png",
29   "--title", uc($name)." Demo", 
30   "--start", "$start + 1 h",
31   "--end", "start + 1000 min",
32   "--interlace", 
33   "--imgformat","PNG",
34   "--width=450",
35   "DEF:a=$rrd:a:AVERAGE",
36   "DEF:b=$rrd:b:AVERAGE",
37   "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
38   "AREA:b#00b6e4:beta",
39   "AREA:line#0022e9:alpha",
40   "LINE3:line#ff0000",
41
42 ;
43
44 if ($ERROR = RRDs::error) {
45   die "ERROR: $ERROR\n";
46 };
47
48
49 print "This script has created $name.png in the current directory\n";
50 print "This demonstrates the use of the TIME and % RPN operators\n";