the legend string of a PRINT command gets renderd later by runnning
[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/\.pl.*//g;
10
11 RRDs::create ($rrd, "--start",$start-1, "--step",300,
12               "DS:a:GAUGE:600:U:U",
13               "DS:b:GAUGE:600:U:U",
14               "RRA:AVERAGE:0.5:1:300");
15 my $ERROR = RRDs::error;
16 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
17
18 # dropt some data into the rrd
19 my $t;
20 for ($t=$start; $t<$start+300*300; $t+=300){
21   RRDs::update $rrd, "$t:".rand(100).":".(sin($t/800)*50+50);
22   if ($ERROR = RRDs::error) {
23     die "$0: unable to update `$rrd': $ERROR\n";
24   }
25 }
26
27 RRDs::graph "$name.png",
28   "--title", uc($name)." Demo", 
29   "--start", "$start + 1 h",
30   "--end", "start + 1000 min",
31   "--interlace", 
32   "--imgformat","PNG",
33   "--width=450",
34   "DEF:a=$rrd:a:AVERAGE",
35   "DEF:b=$rrd:b:AVERAGE",
36   "CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
37   "AREA:b#00b6e4:beta",
38   "AREA:line#0022e9:alpha",
39   "LINE3:line#ff0000",
40
41 ;
42
43 if ($ERROR = RRDs::error) {
44   print "ERROR: $ERROR\n";
45 };
46
47
48 print "This script has created $name.png in the current directory\n";
49 print "This demonstrates the use of the TIME and % RPN operators\n";