vnames MUST start with a letter
[rrdtool.git] / examples / stripes.pl.in
1 #! @PERL@
2 use lib qw( @prefix@/lib/perl );
3
4 use strict;
5 use vars qw(@ISA $loaded);
6
7 use RRDs;
8 my $start=time;
9 my $rrd="random.rrd";
10 RRDs::create ($rrd, "--start",$start-1, "--step",300,
11               "DS:a:GAUGE:600:U:U",
12               "DS:b:GAUGE:600:U:U",
13               "RRA:AVERAGE:0.5:1:200");
14 my $ERROR = RRDs::error;
15 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
16 my $t;
17 for ($t=$start; $t<$start+200*300; $t+=300){
18   RRDs::update $rrd, "$t:".rand(100).":".(sin($t/800)*50+50);
19   if ($ERROR = RRDs::error) {
20     die "$0: unable to update `$rrd': $ERROR\n";
21   }
22 }
23 RRDs::graph "stripes.png",
24   "--title", "Stripes Demo", 
25   "--start", $start,
26   "--end", "start + 400 min",
27   "--interlace", 
28   "--imgformat","PNG",
29   "--width=450",
30   "DEF:a=$rrd:a:AVERAGE",
31   "DEF:b=$rrd:b:AVERAGE",
32   "CDEF:alpha=TIME,1200,%,600,LT,a,UNKN,IF",
33   "CDEF:beta=TIME,1200,%,600,GE,b,UNKN,IF",
34   "AREA:alpha#0022e9:alpha",
35   "AREA:beta#00b674:beta",
36   "LINE1:b#ff4400:beta envelope\\c",
37   "COMMENT:\\s",
38   "COMMENT:alpha=TIME,1200,%,600,LT,a,UNKN,IF",
39   "COMMENT:beta=TIME,1200,%,600,GE,b,UNKN,IF\\j";
40 if ($ERROR = RRDs::error) {
41   print "ERROR: $ERROR\n";
42 };
43
44
45 print "This script has created stripes.png in the current directory\n";
46 print "This demonstrates the use of the TIME and % RPN operators\n";