@cryptotaxi247 / netdata-1 / commits / ec8ead958

operational stream mode - added more descriptive logs for errors

Costa Tsaousis (ktsaou) committed Feb 21, 2017 at 02:55 UTC ec8ead9581f43620c7806f24d827641d870903c4
3 files changed +33 -29
src/plugins_d.c
+13 -12
@@ -144,7 +144,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
144 char *value = words[2];
145
146 if(unlikely(!dimension || !*dimension)) {
147 - error("PLUGINSD: '%s' is requesting a SET on chart '%s', without a dimension. Disabling it.", cd->fullfilename, st->id);
147 + error("PLUGINSD: '%s' is requesting a SET on chart '%s' of host '%s', without a dimension. Disabling it.", cd->fullfilename, st->id, host->hostname);
148 enabled = 0;
149 break;
150 }
@@ -152,7 +152,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
152 if(unlikely(!value || !*value)) value = NULL;
153
154 if(unlikely(!st)) {
155 - error("PLUGINSD: '%s' is requesting a SET on dimension %s with value %s, without a BEGIN. Disabling it.", cd->fullfilename, dimension, value?value:"<nothing>");
155 + error("PLUGINSD: '%s' is requesting a SET on dimension %s with value %s on host '%s', without a BEGIN. Disabling it.", cd->fullfilename, dimension, value?value:"<nothing>", host->hostname);
156 enabled = 0;
157 break;
158 }
@@ -166,14 +166,14 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
166 char *microseconds_txt = words[2];
167
168 if(unlikely(!id)) {
169 - error("PLUGINSD: '%s' is requesting a BEGIN without a chart id. Disabling it.", cd->fullfilename);
169 + error("PLUGINSD: '%s' is requesting a BEGIN without a chart id for host '%s'. Disabling it.", cd->fullfilename, host->hostname);
170 enabled = 0;
171 break;
172 }
173
174 st = rrdset_find(host, id);
175 if(unlikely(!st)) {
176 - error("PLUGINSD: '%s' is requesting a BEGIN on chart '%s', which does not exist. Disabling it.", cd->fullfilename, id);
176 + error("PLUGINSD: '%s' is requesting a BEGIN on chart '%s', which does not exist on host '%s'. Disabling it.", cd->fullfilename, id, host->hostname);
177 enabled = 0;
178 break;
179 }
@@ -193,7 +193,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
193 }
194 else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
195 if(unlikely(!st)) {
196 - error("PLUGINSD: '%s' is requesting an END, without a BEGIN. Disabling it.", cd->fullfilename);
196 + error("PLUGINSD: '%s' is requesting an END, without a BEGIN on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
197 enabled = 0;
198 break;
199 }
@@ -210,12 +210,12 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
210 char *hostname = words[2];
211
212 if(unlikely(!guid || !*guid)) {
213 - error("PLUGINSD: '%s' is requesting a HOST, without a guid. Disabling it.", cd->fullfilename);
213 + error("PLUGINSD: '%s' is requesting HOST with guid '%s' and hostname '%s', without a guid. Disabling it.", cd->fullfilename, guid?guid:"", hostname?hostname:"");
214 enabled = 0;
215 break;
216 }
217 if(unlikely(!hostname || !*hostname)) {
218 - error("PLUGINSD: '%s' is requesting a HOST, without a hostname. Disabling it.", cd->fullfilename);
218 + error("PLUGINSD: '%s' is requesting HOST with guid '%s' and hostname '%s', without a hostname. Disabling it.", cd->fullfilename, guid?guid:"", hostname?hostname:"");
219 enabled = 0;
220 break;
221 }
@@ -249,7 +249,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
249 char *update_every_s = words[9];
250
251 if(unlikely(!type || !*type || !id || !*id)) {
252 - error("PLUGINSD: '%s' is requesting a CHART, without a type.id. Disabling it.", cd->fullfilename);
252 + error("PLUGINSD: '%s' is requesting a CHART, without a type.id, on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
253 enabled = 0;
254 break;
255 }
@@ -294,13 +294,13 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
294 char *options = words[6];
295
296 if(unlikely(!id || !*id)) {
297 - error("PLUGINSD: '%s' is requesting a DIMENSION, without an id. Disabling it.", cd->fullfilename);
297 + error("PLUGINSD: '%s' is requesting a DIMENSION, without an id, host '%s' and chart '%s'. Disabling it.", cd->fullfilename, host->hostname, st?st->id:"UNSET");
298 enabled = 0;
299 break;
300 }
301
302 if(unlikely(!st)) {
303 - error("PLUGINSD: '%s' is requesting a DIMENSION, without a CHART. Disabling it.", cd->fullfilename);
303 + error("PLUGINSD: '%s' is requesting a DIMENSION, without a CHART, on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
304 enabled = 0;
305 break;
306 }
@@ -329,7 +329,8 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
329 RRDDIM *rd = rrddim_find(st, id);
330 if(unlikely(!rd)) {
331 rd = rrddim_add(st, id, name, multiplier, divisor, rrd_algorithm_id(algorithm));
332 - rd->flags = 0x00000000;
332 + rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
333 + rrddim_flag_clear(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
334 if(options && *options) {
335 if(strstr(options, "hidden") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
336 if(strstr(options, "noreset") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
@@ -345,7 +346,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
346 break;
347 }
348 else {
348 - error("PLUGINSD: '%s' is sending command '%s' which is not known by netdata. Disabling it.", cd->fullfilename, s);
349 + error("PLUGINSD: '%s' is sending command '%s' which is not known by netdata, for host '%s'. Disabling it.", cd->fullfilename, s, host->hostname);
350 enabled = 0;
351 break;
352 }
src/rrddim.c
+1 -4
@@ -80,7 +80,6 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
80 rd->id = NULL;
81 rd->name = NULL;
82 rd->cache_filename = NULL;
83 - rd->flags = 0x00000000;
83 rd->variables = NULL;
84 rd->next = NULL;
85 rd->rrdset = NULL;
@@ -164,9 +163,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
163
164 // prevent incremental calculation spikes
165 rd->counter = 0;
167 -
168 - rrddim_flag_clear(rd, RRDDIM_FLAG_UPDATED);
169 - rrddim_flag_clear(rd, RRDDIM_FLAG_EXPOSED);
166 + rd->flags = 0x00000000;
167
168 rd->calculated_value = 0;
169 rd->last_calculated_value = 0;
src/rrdpush.c
+19 -13
@@ -17,16 +17,20 @@ static inline void rrdpush_unlock() {
17 pthread_mutex_unlock(&rrdpush_mutex);
18 }
19
20 -static inline int need_to_send_chart_definitions(RRDSET *st) {
20 +static inline int need_to_send_chart_definition(RRDSET *st) {
21 RRDDIM *rd;
22 rrddim_foreach_read(rd, st)
23 - if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED) && !rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
23 + if(!rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
24 return 1;
25
26 +
27 + // fprintf(stderr, "NOT Sending CHART '%s' '%s'\n", st->id, st->name);
28 return 0;
29 }
30
29 -static inline void send_chart_definitions(RRDSET *st) {
31 +static inline void send_chart_definition(RRDSET *st) {
32 + // fprintf(stderr, "Sending CHART '%s' '%s'\n", st->id, st->name);
33 +
34 buffer_sprintf(rrdpush_buffer, "CHART '%s' '%s' '%s' '%s' '%s' '%s' '%s' %ld %d\n"
35 , st->id
36 , st->name
@@ -59,7 +63,7 @@ static inline void send_chart_metrics(RRDSET *st) {
63
64 RRDDIM *rd;
65 rrddim_foreach_read(rd, st) {
62 - if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED))
66 + if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED) && rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
67 buffer_sprintf(rrdpush_buffer, "SET %s = " COLLECTED_NUMBER_FORMAT "\n"
68 , rd->id
69 , rd->collected_value
@@ -106,8 +110,8 @@ void rrdset_done_push(RRDSET *st) {
110 last_host = st->rrdhost;
111 }
112
109 - if(need_to_send_chart_definitions(st))
110 - send_chart_definitions(st);
113 + if(need_to_send_chart_definition(st))
114 + send_chart_definition(st);
115
116 send_chart_metrics(st);
117
@@ -154,12 +158,6 @@ void *central_netdata_push_thread(void *ptr) {
158 ifd = &fds[0];
159 ofd = &fds[1];
160
157 - ifd->fd = rrdpush_pipe[PIPE_READ];
158 - ifd->events = POLLIN;
159 - ofd->events = POLLOUT;
160 -
161 - nfds_t fdmax = 2;
162 -
161 for(;;) {
162 if(netdata_exit) break;
163
@@ -215,9 +213,15 @@ void *central_netdata_push_thread(void *ptr) {
213 sent_connection = 0;
214 }
215
216 + ifd->fd = rrdpush_pipe[PIPE_READ];
217 + ifd->events = POLLIN;
218 ifd->revents = 0;
219 - ofd->revents = 0;
219 +
220 ofd->fd = sock;
221 + ofd->events = POLLOUT;
222 + ofd->revents = 0;
223 +
224 + nfds_t fdmax = 2;
225
226 if(begin < buffer_strlen(rrdpush_buffer))
227 ofd->events = POLLOUT;
@@ -248,6 +252,8 @@ void *central_netdata_push_thread(void *ptr) {
252 }
253
254 if(ofd->revents & POLLOUT && begin < buffer_strlen(rrdpush_buffer)) {
255 + // info("PUSH: send buffer is ready, sending %zu bytes starting at %zu", buffer_strlen(rrdpush_buffer) - begin, begin);
256 +
257 // fprintf(stderr, "PUSH BEGIN\n");
258 // fwrite(&rrdpush_buffer->buffer[begin], 1, buffer_strlen(rrdpush_buffer) - begin, stderr);
259 // fprintf(stderr, "\nPUSH END\n");