index ff7e2986911cc6c484341894317dd77874b4397a..8606e76841efce2698bf881ad1a5d3d8eb2d5780 100755 (executable)
--- a/contrib/rrdjig/rrdjig.pl
+++ b/contrib/rrdjig/rrdjig.pl
@tmpl = split /:/, $opt{'src-tmpl'};
}
my %map;
- my @min;
- my @max;
for my $cf (keys %$tasks){
print STDERR "FETCH #### CF $cf #####################################\n"
if $opt{verbose};
print STDERR "FETCH: want setp $t->{step} -> got step $step / want start $t->{start} -> got start $start\n" if $opt{verbose};
my $now = $start;
while (my $row = shift @$array){
- for (my $i = 0;$i < scalar @$array;$i++){
- if (defined $row->[$i]){
- $min[$i] = $row->[$i] if not defined $min[$i] or $row->[$i] < $min[$i];
- $max[$i] = $row->[$i] if not defined $max[$i] or $row->[$i] > $max[$i];
- }
- }
if (@tmpl){
push @{$data{$cf}} , [ $now, $step, [ @$row[@map{@tmpl}] ] ];
}
my $step = $start - $first;
unshift @{$data{AVERAGE}}, [ $start, $step, [ map {undef} @{$data{AVERAGE}[0][2]} ] ];
}
- if (@tmpl){
- return (\%data,[@min[@map{@tmpl}]],[@max[@map{@tmpl}]]);
- }
- else {
- return (\%data,\@min,\@max);
- }
+ return (\%data);
}
-sub reupdate($$$$$){
+sub reupdate($$$$){
my $step = shift;
+ my $min_time = shift;
my $dst = shift;
my $data = shift;
- my $min = shift;
- my $max = shift;
+ my @min;
+ my @max;
my @pending = map { 0 } @{$data->{AVERAGE}[0][2]};
my $hide_cnt = 0;
my @up;
my $crow = $m->[2];
if ($cend >= $t and $cend - $cstep <= $t - $step){
my $row = "$t:".join(':',map {defined $_ ? $_ : 'U'} @{$crow});
- print STDERR ($cf eq 'MIN' ? 'm' : 'M' ) ,$row,"\n" if $opt{verbose};
- push @up, $row;
+ if ($cf eq 'MIN'){
+ @min = @{$crow};
+ } else {
+ @max = @{$crow};
+ }
+ if ($t > $min_time){
+ print STDERR ($cf eq 'MIN' ? 'm' : 'M' ) ,$row,"\n" if $opt{verbose};
+ push @up, $row;
+ }
$hide_cnt++;
for (my $i = 0; $i <@$crow; $i++){
if (defined $pending[$i]){
for (my $i = 0; $i < @out; $i++){
if (defined $out[$i] and defined $pending[$i] and $pending[$i] != 0){
my $new = $out[$i] + $pending[$i];
- if (defined $max->[$i] and $new > $max->[$i]) {
- $pending[$i] = $new - $max->[$i];
- $out[$i] = $max->[$i];
+ if (defined $max[$i] and $new > $max[$i]) {
+ $pending[$i] = $new - $max[$i];
+ $out[$i] = $max[$i];
# print STDERR " - maxout $i $out[$i]\n" if $opt{verbose};
}
- elsif (defined $min->[$i] and $new < $min->[$i]){
- $pending[$i] = $new - $min->[$i];
- $out[$i] = $min->[$i];
+ elsif (defined $min[$i] and $new < $min[$i]){
+ $pending[$i] = $new - $min[$i];
+ $out[$i] = $min[$i];
# print STDERR " - minout $i $out[$i]\n" if $opt{verbose};
}
else {
$hide_cnt = 0;
# show the result;
my $row = "$t:".join(':',map {defined $_ ? $_ : 'U'} @out);
- print STDERR " ",$row,"\n" if $opt{verbose};
- push @up, $row;
+ if ($t > $min_time){
+ print STDERR " ",$row,"\n" if $opt{verbose};
+ push @up, $row;
+ }
}
}
pop @up; # the last update is most likely one too many ...
if (@up == 0) {
warn "WARNING: src has no entries new enough to fill dst\n";
} else {
+ print "$min_time $up[0]\n";
RRDs::update($dst,
$opt{'dst-tmpl'} ? '--template='.$opt{'dst-tmpl'} : (),
@up);
my $src_info = RRDs::info($src);
rrd_err_check();
my ($first,$fetch_tasks) = prep_fetch_tasks($src_info,$dst_info);
- my ($updates,$min,$max) = fetch_data($src,$first,$fetch_tasks);
+ my $updates = fetch_data($src,$first,$fetch_tasks);
set_gauge($dst,$dst_info);
- reupdate($src_info->{step},$dst,$updates,$min,$max);
+ reupdate($src_info->{step},$dst_info->{last_update},$dst,$updates);
unset_gauge($dst,$dst_info);
}