3 #makes things work when run without install
4 use lib qw( @prefix@/lib/perl );
14 RRDs::create ($rrd, "--start",$start-1, "--step",300,
17 "RRA:AVERAGE:0.5:1:300",
22 my $ERROR = RRDs::error;
23 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
25 # dropt some data into the rrd
27 for ($t=$start; $t<$start+300*300; $t+=300){
28 RRDs::update $rrd, "$t:".(sin($t/3000)*50+50).":".(sin($t/2500)*50+50);
29 if ($ERROR = RRDs::error) {
30 die "$0: unable to update `$rrd': $ERROR\n";
39 RRDs::graph "$name-L.png",
48 "DEF:a=$rrd:a:AVERAGE",
49 "DEF:b=$rrd:b:AVERAGE",
50 "LINE1:a#$c1:Value A",
51 "LINE3:b#$c2:Value B",
54 RRDs::graph "$name-A.png",
55 "--title", "LINE and AREA",
63 "DEF:a=$rrd:a:AVERAGE",
64 "DEF:b=$rrd:b:AVERAGE",
66 "LINE2:b#$c2:Value B",
69 RRDs::graph "$name-S.png",
70 "--title", "STACKED AREAS",
78 "DEF:a=$rrd:a:AVERAGE",
79 "DEF:b=$rrd:b:AVERAGE",
81 "STACK:b#$c2:Value B",
85 RRDs::graph "$name-M.png",
86 "--title", "RPN Magic",
94 "DEF:a=$rrd:a:AVERAGE",
95 "DEF:b=$rrd:b:AVERAGE",
96 "CDEF:alpha=TIME,3600,%,1800,LT,a,UNKN,IF",
97 "CDEF:beta=TIME,3600,%,1800,GE,b,UNKN,IF",
98 "AREA:alpha#$c1:Value A",
100 "AREA:beta#$c2:Value B",
104 RRDs::graph "$name-sample.png",
107 "--end", "start+15h",
113 "DEF:a=$rrd:a:AVERAGE",
115 "AREA:a#00ff00:Incoming",
116 "LINE1:b#ff0000:Max Incoming",
119 if ($ERROR = RRDs::error) {
120 die "ERROR: $ERROR\n";
123 print "This script has created $name.png in the current directory\n";
124 print "This demonstrates the use of the TIME and % RPN operators\n";