From 923710084cd4b2aacf77da4feffd72fa7b4df2e3 Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 21 Dec 2010 16:38:48 +0000 Subject: [PATCH] 1) Sigma calculation had an error. The first data value in each bin didn't get squared. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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/program@2155 a5681a0c-68f1-0310-ab6d-d61299d08faa --- NEWS | 5 +++++ doc/rrdgraph_libdbi.pod | 6 +++--- src/rrd_fetch_libdbi.c | 26 +++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 0c593af..8a48192 100644 --- a/NEWS +++ b/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/doc/rrdgraph_libdbi.pod b/doc/rrdgraph_libdbi.pod index c84465d..1e4aa4d 100644 --- a/doc/rrdgraph_libdbi.pod +++ b/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/src/rrd_fetch_libdbi.c b/src/rrd_fetch_libdbi.c index 2c4c722..b4f0fc7 100644 --- a/src/rrd_fetch_libdbi.c +++ b/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; } -- 2.30.2