1 #! /usr/sepp/bin/perl
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 use RRDs;
9 my $start=time;
10 my $rrd="randome.rrd";
11 my $name = $0;
12 $name =~ s/\.pl.*//g;
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 "RRA:MIN:0.5:12:300",
19 "RRA:MAX:0.5:12:300",
20 );
22 my $ERROR = RRDs::error;
23 die "$0: unable to create `$rrd': $ERROR\n" if $ERROR;
25 # dropt some data into the rrd
26 my $t;
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";
31 }
32 }
34 $c1="f57912a0";
35 $c2="2a79e9a0";
36 $w=300;
37 $h=140;
38 RRDs::graph "$name-L.png",
39 "--title", "2 LINES",
40 "--start", "now",
41 "--end", "start+15h",
42 "--lower-limit=0",
43 "--interlace",
44 "--imgformat","PNG",
45 "--width=$w",
46 "--height=$h",
47 "DEF:a=$rrd:a:AVERAGE",
48 "DEF:b=$rrd:b:AVERAGE",
49 "LINE1:a#$c1:Value A",
50 "LINE3:b#$c2:Value B",
51 ;
53 RRDs::graph "$name-A.png",
54 "--title", "LINE and AREA",
55 "--start", "now",
56 "--end", "start+15h",
57 "--lower-limit=0",
58 "--interlace",
59 "--imgformat","PNG",
60 "--width=$w",
61 "--height=$h",
62 "DEF:a=$rrd:a:AVERAGE",
63 "DEF:b=$rrd:b:AVERAGE",
64 "AREA:a#$c1:Value A",
65 "LINE2:b#$c2:Value B",
66 ;
68 RRDs::graph "$name-S.png",
69 "--title", "STACKED AREAS",
70 "--start", "now",
71 "--end", "start+15h",
72 "--lower-limit=0",
73 "--interlace",
74 "--imgformat","PNG",
75 "--width=$w",
76 "--height=$h",
77 "DEF:a=$rrd:a:AVERAGE",
78 "DEF:b=$rrd:b:AVERAGE",
79 "AREA:a#$c1:Value A",
80 "STACK:b#$c2:Value B",
81 ;
84 RRDs::graph "$name-M.png",
85 "--title", "RPN Magic",
86 "--start", "now",
87 "--end", "start+15h",
88 "--lower-limit=0",
89 "--interlace",
90 "--imgformat","PNG",
91 "--width=$w",
92 "--height=$h",
93 "DEF:a=$rrd:a:AVERAGE",
94 "DEF:b=$rrd:b:AVERAGE",
95 "CDEF:alpha=TIME,3600,%,1800,LT,a,UNKN,IF",
96 "CDEF:beta=TIME,3600,%,1800,GE,b,UNKN,IF",
97 "AREA:alpha#$c1:Value A",
98 "LINE1:a#$c1",
99 "AREA:beta#$c2:Value B",
100 "LINE1:b#$c2",
101 ;
103 RRDs::graph "$name-sample.png",
104 "--title", "Sample",
105 "--start", "now",
106 "--end", "start+15h",
107 "--lower-limit=0",
108 "--interlace",
109 "--imgformat","PNG",
110 "--width=600",
111 "--height=50",
112 "DEF:a=$rrd:a:AVERAGE",
113 "DEF:b=$rrd:a:MAX",
114 "AREA:a#00ff00:Incoming",
115 "LINE1:b#ff0000:Max Incoming",
116 ;
120 print "ERROR: $ERROR\n" if $ERROR = RRDs::error;
125 print "This script has created $name.png in the current directory\n";
126 print "This demonstrates the use of the TIME and % RPN operators\n";