Ticket #178: overlap.pl

File overlap.pl, 1.6 KB (added by human, 19 months ago)

script to re-create the bug

Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use RRDs '1.3';
7
8#################################################################
9
10my $bad = 'bad.rrd';
11my $good = 'good.rrd';
12my $rows = 40;
13my $step = 10;
14
15my $now = time();
16my $start = $now - ($rows+1)*$step;
17$start -= $start % $step;
18
19for my $file ($bad, $good)
20{
21    unlink($file);
22    RRDs::create($file,
23                 '--start' => $start,
24                 '--step'  => $step,
25                 'DS:now:GAUGE:500:0:U',
26                 "RRA:AVERAGE:0.5:1:$rows",
27                 "RRA:MIN:0.5:6:$rows",
28             );
29
30    $_ and die $_ for (RRDs::error);
31}
32
33my @updates =
34    map { "$_:$_" }
35    grep { $_ % $step == 0 }
36    $start+$step .. $now+$step*8;
37
38###################################
39## illustrate the difference.
40
41RRDs::update($bad, @updates);
42$_ and die $_ for (RRDs::error);
43
44for my $up (@updates)
45{
46    RRDs::update($good, $up);
47}
48
49###################################
50## just where to look
51
52my $info = RRDs::info($bad);
53my $lastup = $info->{last_update};
54
55my $empty = $info->{'rra[0].rows'} - $info->{'rra[0].cur_row'} - 1;
56my $empty_time = $lastup - $info->{'rra[0].cur_row'} * $step;
57
58print "rra[0] row $empty for time $empty_time is NaN, but it shouldn't be ...\n";
59
60###################################
61
62my $cf_step = $step * $info->{'rra[1].pdp_per_row'};
63
64my $corrupt = $info->{'rra[1].rows'} - $info->{'rra[1].rows'} - 1;
65my $corrupt_time
66    = $lastup
67    - $lastup % $cf_step
68    - $info->{'rra[1].cur_row'} * $cf_step;
69
70print "rra[1] row 0 for time $corrupt_time contains the value $empty_time!\n";
71
72###################################

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.