From: oetiker Date: Tue, 21 Dec 2010 16:38:48 +0000 (+0000) Subject: 1) Sigma calculation had an error. The first data value in each bin didn't get squared. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8ccce39eed8f701c270c9aa0755df9058609d552;p=rrdtool-all.git 1) Sigma calculation had an error. The first data value in each bin didn't get squared. 2) "rrdfillmissing" was dummy. I have added code to do the work. The parameter has NOW to be in seconds. In doc it is given in steps. The size of steps depends to much on size of graph so I think its easier to use seconds and internal calculate the number of steps. by Hans Jørgen Jakobsen git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2155 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/NEWS b/program/NEWS index 0c593af4..8a48192a 100644 --- a/program/NEWS +++ b/program/NEWS @@ -27,6 +27,11 @@ API --- * exported rrd_update_v_r for theadsave rrd_update calls +libDBI +------ +* make rrdfillmissing actually work. The parameter is now in seconds and not + in steps for ease of use by Hans Jørgen Jakobsen + Bindings -------- * dotnet by Chris Larsen of Euphoria Audio diff --git a/program/doc/rrdgraph_libdbi.pod b/program/doc/rrdgraph_libdbi.pod index c84465d8..1e4aa4db 100644 --- a/program/doc/rrdgraph_libdbi.pod +++ b/program/doc/rrdgraph_libdbi.pod @@ -4,7 +4,7 @@ rrdgraph_libdbi - fetching data for graphing in rrdtool graph via libdbi =head1 SYNOPSIS -ErrdfileE = Blibdbi driverE/Edriver-option-nameE=Edriver-option-valueE/...[/rrdminstepsize=EstepsizeE][/rrdfillmissing=Efill missing n samplesE]//EtableE/Eunixtimestamp columnE/Edata value columnE[/derive]/Ewhere clause 1E/.../Ewhere clause nE> +ErrdfileE = Blibdbi driverE/Edriver-option-nameE=Edriver-option-valueE/...[/rrdminstepsize=EstepsizeE][/rrdfillmissing=Efill missing n secondsE]//EtableE/Eunixtimestamp columnE/Edata value columnE[/derive]/Ewhere clause 1E/.../Ewhere clause nE> =head1 DESCRIPTION @@ -29,9 +29,9 @@ This pseudo-rrd-filename defines a sql datasource: defines the minimum number of the step-length used for graphing (default: 300 seconds) -=item B=Bfill missing stepsE> +=item B=Bfill missing secondsE> - defines the number of steps to fill with the last value to avoid NaN boxes due to data-insertation jitter (default: 0 steps) + defines the number of seconds to fill with the last value to avoid NaN boxes due to data-insertation jitter (default: 0 seconds) =item BtableE> diff --git a/program/src/rrd_fetch_libdbi.c b/program/src/rrd_fetch_libdbi.c index 2c4c722e..b4f0fc79 100644 --- a/program/src/rrd_fetch_libdbi.c +++ b/program/src/rrd_fetch_libdbi.c @@ -615,7 +615,7 @@ rrd_fetch_fn_libdbi( (*data)[idx*(*ds_cnt)+1]=r_value; /* AVG */ (*data)[idx*(*ds_cnt)+2]=r_value; /* MAX */ (*data)[idx*(*ds_cnt)+3]=1; /* COUNT */ - (*data)[idx*(*ds_cnt)+4]=r_value; /* SIGMA */ + (*data)[idx*(*ds_cnt)+4]=r_value*r_value; /* SIGMA */ } else { /* MIN */ if ((*data)[idx*(*ds_cnt)+0]>r_value) { (*data)[idx*(*ds_cnt)+0]=r_value; } @@ -652,6 +652,30 @@ rrd_fetch_fn_libdbi( } } + /* Fill in missing values */ + fillmissing/=(*step);/* Convert from seconds to steps */ + if (fillmissing>0) { + int copy_left=fillmissing; + for(idx=1;idx0) { + /* But we can copy from previous */ + int idx_p=idx-1; + (*data)[idx*(*ds_cnt)+0]=(*data)[idx_p*(*ds_cnt)+0]; + (*data)[idx*(*ds_cnt)+1]=(*data)[idx_p*(*ds_cnt)+1]; + (*data)[idx*(*ds_cnt)+2]=(*data)[idx_p*(*ds_cnt)+2]; + (*data)[idx*(*ds_cnt)+3]=(*data)[idx_p*(*ds_cnt)+3]; + (*data)[idx*(*ds_cnt)+4]=(*data)[idx_p*(*ds_cnt)+4]; + copy_left--; + } + }else{ + copy_left=fillmissing; + } + } + } + /* and return OK */ return 0; }