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