when a chart is obsolete, its definition has to be pushed upstream manually
Costa Tsaousis (ktsaou) committed
Jul 2, 2017 at 20:09 UTC
f6981ae454f943726c10f9b8243bfc7d0f00f857
3 files changed
+21
-1
src/rrdpush.c
+12
-1
@@ -77,6 +77,8 @@ static inline int need_to_send_chart_definition(RRDSET *st) {
77
78
// sends the current chart definition
79
static inline void send_chart_definition(RRDSET *st) {
80
+ rrdset_flag_set(st, RRDSET_FLAG_EXPOSED_UPSTREAM);
81
+
82
buffer_sprintf(st->rrdhost->rrdpush_buffer, "CHART \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" %ld %d \"%s %s\"\n"
83
, st->id
84
, st->name
@@ -106,7 +108,6 @@ static inline void send_chart_definition(RRDSET *st) {
108
}
109
110
st->upstream_resync_time = st->last_collected_time.tv_sec + (remote_clock_resync_iterations * st->update_every);
109
- rrdset_flag_set(st, RRDSET_FLAG_EXPOSED_UPSTREAM);
111
}
112
113
// sends the current chart dimensions
@@ -127,6 +128,16 @@ static inline void send_chart_metrics(RRDSET *st) {
128
129
static void rrdpush_sender_thread_spawn(RRDHOST *host);
130
131
+void rrdset_push_chart_definition(RRDSET *st) {
132
+ RRDHOST *host = st->rrdhost;
133
+
134
+ rrdset_rdlock(st);
135
+ rrdpush_lock(host);
136
+ send_chart_definition(st);
137
+ rrdpush_unlock(host);
138
+ rrdset_unlock(st);
139
+}
140
+
141
void rrdset_done_push(RRDSET *st) {
142
RRDHOST *host = st->rrdhost;
143
src/rrdpush.h
+1
@@ -8,6 +8,7 @@ extern unsigned int remote_clock_resync_iterations;
8
9
extern int rrdpush_init();
10
extern void rrdset_done_push(RRDSET *st);
11
+extern void rrdset_push_chart_definition(RRDSET *st);
12
extern void *rrdpush_sender_thread(void *ptr);
13
14
extern int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url);
src/rrdset.c
+8
@@ -172,6 +172,11 @@ inline void rrdset_is_obsolete(RRDSET *st) {
172
if(unlikely(!(rrdset_flag_check(st, RRDSET_FLAG_OBSOLETE)))) {
173
rrdset_flag_set(st, RRDSET_FLAG_OBSOLETE);
174
rrdset_flag_clear(st, RRDSET_FLAG_EXPOSED_UPSTREAM);
175
+
176
+ // the chart will not get more updates (data collection)
177
+ // so, we have to push its definition now
178
+ if(unlikely(host->rrdpush_enabled))
179
+ rrdset_push_chart_definition(st);
180
}
181
}
182
@@ -179,6 +184,9 @@ inline void rrdset_isnot_obsolete(RRDSET *st) {
184
if(unlikely((rrdset_flag_check(st, RRDSET_FLAG_OBSOLETE)))) {
185
rrdset_flag_clear(st, RRDSET_FLAG_OBSOLETE);
186
rrdset_flag_clear(st, RRDSET_FLAG_EXPOSED_UPSTREAM);
187
+
188
+ // the chart will be pushed upstream automatically
189
+ // due to data collection
190
}
191
}
192