From: oetiker Date: Fri, 2 Apr 2010 08:58:01 +0000 (+0000) Subject: make sure we do not add updates 'before' the fact X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=91446f44f6d7b02293d23415ddf5d2c8a22c39fd;p=rrdtool-all.git make sure we do not add updates 'before' the fact git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2063 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/contrib/rrdjig/rrdjig.pl b/contrib/rrdjig/rrdjig.pl index 7c90f622..8e56660c 100755 --- a/contrib/rrdjig/rrdjig.pl +++ b/contrib/rrdjig/rrdjig.pl @@ -36,6 +36,12 @@ sub rrd_err_check(){ die "RRD Error: $err\n"; } } +sub rrd_warn_check(){ + my $err = RRDs::error(); + if ($err){ + warn "RRD Warning: $err\n"; + } +} # how should the data be fetched from the source # to provide the best approximation of the original data @@ -163,8 +169,9 @@ sub fetch_data($$$){ return (\%data); } -sub reupdate($$$){ +sub reupdate($$$$){ my $step = shift; + my $min_time = shift; my $dst = shift; my $data = shift; my @min; @@ -252,18 +259,19 @@ sub reupdate($$$){ $hide_cnt = 0; # show the result; my $row = "$t:".join(':',map {defined $_ ? $_ : 'U'} @out); - print STDERR " ",$row,"\n" if $opt{verbose}; - push @up, $row; + print STDERR " ",$row,"\n" if $opt{verbose}; + push @up, $row if $t > $min_time; } } 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 STDERR "."; RRDs::update($dst, $opt{'dst-tmpl'} ? '--template='.$opt{'dst-tmpl'} : (), @up); - rrd_err_check(); + rrd_warn_check(); } } @@ -313,7 +321,7 @@ sub rrdjig($$$$){ my ($first,$fetch_tasks) = prep_fetch_tasks($src_info,$dst_info); my $updates = fetch_data($src,$first,$fetch_tasks); set_gauge($dst,$dst_info); - reupdate($src_info->{step},$dst,$updates); + reupdate($src_info->{step},$dst_info->{last_update},$dst,$updates); unset_gauge($dst,$dst_info); }