do not show gaps on the charts of a netdata slave when the master is not available
Costa Tsaousis (ktsaou) committed
Jun 8, 2017 at 23:29 UTC
cf5db3d85712ee100208d08834b94ce9de7faa78
3 files changed
+9
-5
src/rrd.h
+2
-1
@@ -281,7 +281,8 @@ struct rrdset {
281
size_t counter_done; // the number of times rrdset_done() has been called
282
283
time_t last_accessed_time; // the last time this RRDSET has been accessed
284
- size_t unused[9];
284
+ time_t upstream_resync_time; // the timestamp up to which we should resync clock upstream
285
+ size_t unused[8];
286
287
uint32_t hash; // a simple hash on the id, to speed up searching
288
// we first compare hashes, and only if the hashes are equal we do string comparisons
src/rrdpush.c
+4
-4
@@ -99,11 +99,13 @@ static inline void send_chart_definition(RRDSET *st) {
99
);
100
rd->exposed = 1;
101
}
102
+
103
+ st->upstream_resync_time = st->last_collected_time.tv_sec + (remote_clock_resync_iterations * st->update_every);
104
}
105
106
// sends the current chart dimensions
107
static inline void send_chart_metrics(RRDSET *st) {
106
- buffer_sprintf(st->rrdhost->rrdpush_buffer, "BEGIN %s %llu\n", st->id, (st->counter_done > remote_clock_resync_iterations)?st->usec_since_last_update:0);
108
+ buffer_sprintf(st->rrdhost->rrdpush_buffer, "BEGIN %s %llu\n", st->id, (st->upstream_resync_time > st->last_collected_time.tv_sec)?st->usec_since_last_update:0);
109
110
RRDDIM *rd;
111
rrddim_foreach_read(rd, st) {
@@ -167,9 +169,7 @@ static void rrdpush_sender_thread_reset_all_charts(RRDHOST *host) {
169
RRDSET *st;
170
rrdset_foreach_read(st, host) {
171
170
- // make it re-align the current time
171
- // on the remote host
172
- st->counter_done = 0;
172
+ st->upstream_resync_time = 0;
173
174
rrdset_rdlock(st);
175
src/rrdset.c
+3
@@ -558,6 +558,9 @@ RRDSET *rrdset_create_custom(
558
st->gap_when_lost_iterations_above = (int) (
559
config_get_number(st->config_section, "gap when lost iterations above", RRD_DEFAULT_GAP_INTERPOLATIONS) + 2);
560
561
+ st->last_accessed_time = 0;
562
+ st->upstream_resync_time = 0;
563
+
564
avl_init_lock(&st->dimensions_index, rrddim_compare);
565
avl_init_lock(&st->variables_root_index, rrdvar_compare);
566