]> arthur.barton.de Git - netdata.git/commitdiff
detect too big updates correctly
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 Mar 2015 09:10:03 +0000 (11:10 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 Mar 2015 09:10:03 +0000 (11:10 +0200)
src/rrd.c

index 063d036640e16b4999ab73e1269ad0471213b92d..8653bef2698a9a3773ebf026e1d5a261185c5d3f 100755 (executable)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -174,6 +174,8 @@ void rrd_stats_reset(RRD_STATS *st)
 {
        st->last_collected_time.tv_sec = 0;
        st->last_collected_time.tv_usec = 0;
+       st->last_updated.tv_sec = 0;
+       st->last_updated.tv_usec = 0;
        st->current_entry = 0;
        st->counter_done = 0;
 
@@ -609,11 +611,6 @@ void rrd_stats_next_usec(RRD_STATS *st, unsigned long long microseconds)
        debug(D_RRD_STATS, "rrd_stats_next() for chart %s with microseconds %llu", st->name, microseconds);
 
        if(st->debug) debug(D_RRD_STATS, "%s: NEXT: %llu microseconds", st->name, microseconds);
-       if(microseconds > st->entries * st->update_every * 1000000ULL) {
-               info("History of chart %s too old. Reseting chart.", st->name);
-               rrd_stats_reset(st);
-               microseconds = st->update_every * 1000000ULL;
-       }
        st->usec_since_last_update = microseconds;
 }
 
@@ -648,6 +645,12 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
        // a read lock is OK here
        pthread_rwlock_rdlock(&st->rwlock);
 
+       if(st->usec_since_last_update > st->entries * st->update_every * 1000000ULL) {
+               info("History of chart %s too old. Reseting chart.", st->name);
+               rrd_stats_reset(st);
+               st->usec_since_last_update = st->update_every * 1000000ULL;
+       }
+
        if(st->debug) debug(D_RRD_STATS, "%s: microseconds since last update: %llu", st->name, st->usec_since_last_update);
 
        if(!st->last_collected_time.tv_sec) gettimeofday(&st->last_collected_time, NULL);