*/
#include <sys/timeb.h>
+#ifndef __MINGW32__
struct timeval {
time_t tv_sec; /* seconds */
long tv_usec; /* microseconds */
};
+#endif
struct __timezone {
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
-static gettimeofday(struct timeval *t, struct __timezone *tz) {
-
- struct timeb current_time;
+static int gettimeofday(struct timeval *t, struct __timezone *tz) {
+
+ struct _timeb current_time;
_ftime(¤t_time);
-
+
t->tv_sec = current_time.time;
t->tv_usec = current_time.millitm * 1000;
+
+ return 0;
}
#endif
for(i=0;i<rrd.stat_head->ds_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"
pdp_temp[] will contain the rate for cdp */
for(i=0;i<rrd.stat_head->ds_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;
/* 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 =