From: oetiker Date: Sat, 27 Aug 2005 21:29:21 +0000 (+0000) Subject: resolve subsecond resolution logging and handling of unknown values by X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e9e2ef19532f8d3aadbd27cd38c2e953f131a36d;p=rrdtool.git resolve subsecond resolution logging and handling of unknown values by starting off with an unknown value when building a pdp instead of starting out with 0 and then turning it into unknown later on if the number of uknown seconds is equal or larger than the interval ... git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@678 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_update.c b/src/rrd_update.c index e8d629e..5c42f92 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -733,9 +733,14 @@ _rrd_update(char *filename, char *template, int argc, char **argv, for(i=0;ids_cnt;i++){ if(isnan(pdp_new[i])) - rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt += floor(interval-0.5); - else - rrd.pdp_prep[i].scratch[PDP_val].u_val+= pdp_new[i]; + rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt += floor(interval+0.5); + else { + if (isnan( rrd.pdp_prep[i].scratch[PDP_val].u_val )){ + rrd.pdp_prep[i].scratch[PDP_val].u_val= pdp_new[i]; + } else { + rrd.pdp_prep[i].scratch[PDP_val].u_val+= pdp_new[i]; + } + } #ifdef DEBUG fprintf(stderr, "NO PDP ds[%lu]\t" @@ -755,16 +760,25 @@ _rrd_update(char *filename, char *template, int argc, char **argv, pdp_temp[] will contain the rate for cdp */ for(i=0;ids_cnt;i++){ - /* update pdp_prep to the current pdp_st */ + /* update pdp_prep to the current pdp_st. */ + if(isnan(pdp_new[i])) rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt += floor(pre_int+0.5); - else - rrd.pdp_prep[i].scratch[PDP_val].u_val += - pdp_new[i]/interval*pre_int; + else { + if (isnan( rrd.pdp_prep[i].scratch[PDP_val].u_val )){ + rrd.pdp_prep[i].scratch[PDP_val].u_val= pdp_new[i]/interval*pre_int; + } else { + rrd.pdp_prep[i].scratch[PDP_val].u_val+= pdp_new[i]/interval*pre_int; + } + } + /* if too much of the pdp_prep is unknown we dump it */ - if ((rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt - > rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt) || + if ( + /* removed because this does not agree with the definition + a heart beat can be unknown */ + /* (rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt + > rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt) || */ (occu_pdp_st-proc_pdp_st <= rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt)) { pdp_temp[i] = DNAN; @@ -798,7 +812,7 @@ _rrd_update(char *filename, char *template, int argc, char **argv, /* make pdp_prep ready for the next run */ if(isnan(pdp_new[i])){ rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt = floor(post_int + 0.5); - rrd.pdp_prep[i].scratch[PDP_val].u_val = 0.0; + rrd.pdp_prep[i].scratch[PDP_val].u_val = DNAN; } else { rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt = 0; rrd.pdp_prep[i].scratch[PDP_val].u_val =