The BIG graph update
[rrdtool.git] / examples / minmax.pl.in
1 #! @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( @prefix@/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               "RRA:AVERAGE:0.5:1:300",
17               "RRA:MIN:0.5:12:300",
18               "RRA:MAX:0.5:12:300",
19 );
20 my $ERROR = RRDs::error;
21 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
22
23 # dropt some data into the rrd
24 my $t;
25 for ($t=$start; $t<$start+300*300; $t+=300){
26   RRDs::update $rrd, "$t:".(sin($t/3000)*50+50);
27   if ($ERROR = RRDs::error) {
28     die "$0: unable to update `$rrd': $ERROR\n";
29   }
30 }
31
32 RRDs::graph "$name.png",
33   "--title", uc($name)." Demo", 
34   "--start", "now",
35   "--end", "start+1d",
36   "--lower-limit=0",
37   "--interlace", 
38   "--imgformat","PNG",
39   "--width=450",
40   "DEF:a=$rrd:a:AVERAGE",
41   "DEF:b=$rrd:a:MIN",
42   "DEF:c=$rrd:a:MAX",
43   "AREA:a#00b6e4:real",
44   "LINE1:b#0022e9:min",
45   "LINE1:c#00ee22:max",
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";