From 8ef395a417863fef9d2653b108fc7cc0c2be7ece Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Thu, 19 Mar 2015 11:10:03 +0200 Subject: [PATCH] detect too big updates correctly --- src/rrd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/rrd.c b/src/rrd.c index 063d0366..8653bef2 100755 --- 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); -- 2.39.2