detect too big updates correctly
Costa Tsaousis (ktsaou) committed
Mar 19, 2015 at 11:10 UTC
8ef395a417863fef9d2653b108fc7cc0c2be7ece
1 file changed
+8
-5
src/rrd.c
+8
-5
@@ -174,6 +174,8 @@ void rrd_stats_reset(RRD_STATS *st)
174
{
175
st->last_collected_time.tv_sec = 0;
176
st->last_collected_time.tv_usec = 0;
177
+ st->last_updated.tv_sec = 0;
178
+ st->last_updated.tv_usec = 0;
179
st->current_entry = 0;
180
st->counter_done = 0;
181
@@ -609,11 +611,6 @@ void rrd_stats_next_usec(RRD_STATS *st, unsigned long long microseconds)
611
debug(D_RRD_STATS, "rrd_stats_next() for chart %s with microseconds %llu", st->name, microseconds);
612
613
if(st->debug) debug(D_RRD_STATS, "%s: NEXT: %llu microseconds", st->name, microseconds);
612
- if(microseconds > st->entries * st->update_every * 1000000ULL) {
613
- info("History of chart %s too old. Reseting chart.", st->name);
614
- rrd_stats_reset(st);
615
- microseconds = st->update_every * 1000000ULL;
616
- }
614
st->usec_since_last_update = microseconds;
615
}
616
@@ -648,6 +645,12 @@ unsigned long long rrd_stats_done(RRD_STATS *st)
645
// a read lock is OK here
646
pthread_rwlock_rdlock(&st->rwlock);
647
648
+ if(st->usec_since_last_update > st->entries * st->update_every * 1000000ULL) {
649
+ info("History of chart %s too old. Reseting chart.", st->name);
650
+ rrd_stats_reset(st);
651
+ st->usec_since_last_update = st->update_every * 1000000ULL;
652
+ }
653
+
654
if(st->debug) debug(D_RRD_STATS, "%s: microseconds since last update: %llu", st->name, st->usec_since_last_update);
655
656
if(!st->last_collected_time.tv_sec) gettimeofday(&st->last_collected_time, NULL);