Code

initial
[rrdtool-all.git] / tutorial / ouce2013 / rrd-by-example / ex / hw-example.pl
1 #!/usr/bin/perl
2 #$ENV{PATH}='/scratch/rrd4/bin';
3 $ENV{PATH}=$ENV{HOME}.'/checkouts/rrdtool/branches/1.3/program/src:'.$ENV{PATH};
4 my $R=rrdtool;
5 my $w=1600 ;
6 my $h=100 ;
7 my $start = 1199999700;
8 sub cr {
9     system $R,'create','h.rrd',
10           '--step' => 300,
11           '--start' => ($start-1),
12           'DS:a:GAUGE:600:U:U',
13           'RRA:AVERAGE:0.5:1:3100',
14           'RRA:HWPREDICT:3100:0.2:0.01:48';
15     my @updates;
16     for (my $i = 1; $i < 3000;$i++){
17         push @updates, ($i*300+$start).':'.(sin($i*3.14159265/24)*10*(cos($i/100)+3));
19     }
20     system $R,'update','h.rrd',@updates;
21 }
23 sub rg {
24     my $file = shift;
25     print STDERR $file,"\t";
26 #    if (-f $file){
27 #        print STDERR " skip\n";
28 #        return;
29 #    }
30     my @G = ( '--start' => $start-3600,
31               '--end'   => 'start+200h',
32 #              '--full-size-mode',
33               '--color=BACK#ffff',
34               '--color=CANVAS#ffff',
35               '--color=SHADEA#ffff',
36               '--color=SHADEB#ffff',
37               '--lower-limit' => 0,
38               '--pango-markup',
39               '--height' => $h, '--width' => $w,
40               '--imgformat' => 'PDF');
41    system $R, 'graph', $file, @G, @_;
42 }
43 cr;
45 rg 'HW-LINE.pdf', 
46                'DEF:a=h.rrd:a:AVERAGE',
47                'DEF:pred=h.rrd:a:HWPREDICT',
48                'DEF:conf=h.rrd:a:DEVPREDICT',
49                'CDEF:lowc=pred,conf,2,*,-',
50                'CDEF:widc=conf,4,*',
51                'LINE1:lowc',
52                'AREA:widc#cfc::STACK',
53                'LINE1:0#3a1::STACK',
54                'LINE1:lowc#3a1',             
55                'LINE1:a#a00:a\l';            
56 #               'LINE1:pred#0a0:pred\l';