File: 004Template.t

package info (click to toggle)
librrdtool-oo-perl 0.36-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 320 kB
  • ctags: 36
  • sloc: perl: 1,052; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

###########################################
# Test meta data discovery
# Mike Schilli, 2004 (m@perlmeister.com)
###########################################
use warnings;
use strict;

use Test::More qw(no_plan);
use RRDTool::OO;

use Log::Log4perl qw(:easy);
#Log::Log4perl->easy_init({
#    category => 'rrdtool',
#    level    => $INFO, 
#    layout   => "%m%n", 
#    file     => 'stdout'
#});

my $rrd = RRDTool::OO->new(file => "rrdtooltest.rrd");

my $start_time     = 1080460200;

my $rc = $rrd->create(
    start     => $start_time - 10,
    step      => 1,
    data_source => { name      => 'ds1',
                     type      => 'GAUGE',
                   },
    data_source => { name      => 'ds2',
                     type      => 'GAUGE',
                   },
    data_source => { name      => 'ds3',
                     type      => 'GAUGE',
                   },
    archive     => { cfunc    => 'MAX',
                     cpoints  => 1,
                     rows     => 10,
                   },
);

for(0..10) {
    my $time = $start_time + $_;
    $rrd->update(
        time   => $time,
        values => {  "ds1" => 1,
                     "ds2" => 2,
                     "ds3" => 3,
                  },
    );
}

$rrd->fetch_start(start => $start_time, end => $start_time + 10);
$rrd->fetch_skip_undef();
my $count = 0;
while(my($time, @val) = $rrd->fetch_next()) {
    last unless defined $val[0];
    like "$time:@val", qr/\d+:1 2 3/, "values in correct order";
    $count++;
}
is($count, 10, "10 items found");

END { unlink "rrdtooltest.rrd"; }