@cryptotaxi247 / netdata-1 / commits / f01aeea73

move core iteration point in the middle of the second, to give some tollerance to plugins

Costa Tsaousis (ktsaou) committed Nov 15, 2016 at 00:05 UTC f01aeea73a6dc2fbf2ad873b89402653b97b9fef
3 files changed +17 -6
python.d/python_modules/base.py
+1 -1
@@ -148,7 +148,7 @@ class SimpleService(threading.Thread):
148 self.debug("starting data collection - update frequency:", str(step), ", retries allowed:", str(self.retries))
149 while True: # run forever, unless something is wrong
150 now = float(time.time())
151 - next = self.timetable['next'] = now - (now % step) + step + (step / 3) # add 1/3 into the iteration to sync with netdata
151 + next = self.timetable['next'] = now - (now % step) + step
152
153 # it is important to do this in a loop
154 # sleep() is interruptable
src/log.c
+8
@@ -125,7 +125,11 @@ int error_log_limit(int reset) {
125
126 // prevent all logs if the errors per period is 0
127 if(error_log_errors_per_period == 0)
128 +#ifdef NETDATA_INTERNAL_CHECKS
129 + return 0;
130 +#else
131 return 1;
132 +#endif
133
134 time_t now = time(NULL);
135 if(!start) start = now;
@@ -185,7 +189,11 @@ int error_log_limit(int reset) {
189 prevented++;
190
191 // prevent logging this error
192 +#ifdef NETDATA_INTERNAL_CHECKS
193 + return 0;
194 +#else
195 return 1;
196 +#endif
197 }
198
199 return 0;
src/rrd.c
+8 -5
@@ -527,9 +527,12 @@ RRDSET *rrdset_create(const char *type, const char *id, const char *name, const
527 }
528
529 // make sure the database is aligned
530 - if(st->last_updated.tv_sec % update_every) {
531 - st->last_updated.tv_sec -= st->last_updated.tv_sec % update_every;
532 - st->last_updated.tv_usec = 0;
530 + if(st->last_updated.tv_sec) {
531 + if(st->last_updated.tv_sec % update_every)
532 + st->last_updated.tv_sec -= st->last_updated.tv_sec % update_every;
533 +
534 + // aligned in the middle, for tolerance with plugins
535 + st->last_updated.tv_usec = 500000ULL;
536 }
537 }
538
@@ -1103,7 +1106,7 @@ unsigned long long rrdset_done(RRDSET *st)
1106
1107 // align it to update_every
1108 st->last_collected_time.tv_sec -= st->last_collected_time.tv_sec % st->update_every;
1106 - st->last_collected_time.tv_usec = 0;
1109 + st->last_collected_time.tv_usec = 500000ULL;
1110
1111 last_collect_ut = st->last_collected_time.tv_sec * 1000000ULL + st->last_collected_time.tv_usec - update_every_ut;
1112
@@ -1149,7 +1152,7 @@ unsigned long long rrdset_done(RRDSET *st)
1152
1153 // align it to update_every
1154 st->last_collected_time.tv_sec -= st->last_collected_time.tv_sec % st->update_every;
1152 - st->last_collected_time.tv_usec = 0;
1155 + st->last_collected_time.tv_usec = 500000ULL;
1156
1157 unsigned long long ut = st->last_collected_time.tv_sec * 1000000ULL + st->last_collected_time.tv_usec - st->usec_since_last_update;
1158 st->last_updated.tv_sec = (time_t) (ut / 1000000ULL);