@cryptotaxi247 / netdata-1 / commits / b64239951

when sending metrics to backends, check if we just missed an update due to the longer update frequency of the chart; fixes #2334

Costa Tsaousis (ktsaou) committed Jul 3, 2017 at 00:13 UTC b642399514bc599d4746c452e17db5de9e5a8438
1 file changed +14 -7
src/backends.c
+14 -7
@@ -43,10 +43,22 @@ static inline calculated_number backend_calculate_value_from_stored_data(
43 // find the edges of the rrd database for this chart
44 time_t first_t = rrdset_first_entry_t(st);
45 time_t last_t = rrdset_last_entry_t(st);
46 + time_t update_every = st->update_every;
47 +
48 + // align the time-frame
49 + // for 'after' also skip the first value by adding update_every
50 + after = after - after % update_every + update_every;
51 + before = before - before % update_every;
52 +
53 + if(unlikely(after = last_t + update_every)) {
54 + // we missed an update, report the last one
55 + after -= update_every;
56 + before -= update_every;
57 + }
58
59 if(unlikely(before < first_t || after > last_t)) {
60 // the chart has not been updated in the wanted timeframe
49 - debug(D_BACKEND, "BACKEND: %s.%s.%s: requested timeframe %lu to %lu is outside the chart's database range %lu to %lu",
61 + debug(D_BACKEND, "BACKEND: %s.%s.%s: aligned timeframe %lu to %lu is outside the chart's database range %lu to %lu",
62 st->rrdhost->hostname, st->id, rd->id,
63 (unsigned long)after, (unsigned long)before,
64 (unsigned long)first_t, (unsigned long)last_t
@@ -54,16 +66,11 @@ static inline calculated_number backend_calculate_value_from_stored_data(
66 return NAN;
67 }
68
57 - // align the time-frame
58 - // for 'after' also skip the first value by adding st->update_every
59 - after = after - after % st->update_every + st->update_every;
60 - before = before - before % st->update_every;
61 -
69 if(unlikely(after < first_t))
70 after = first_t;
71
72 if(unlikely(after > before))
66 - // this can happen when st->update_every > before - after
73 + // this can happen when update_every > before - after
74 before = after;
75
76 if(unlikely(before > last_t))