]> arthur.barton.de Git - netdata.git/commitdiff
operational stream mode - added more descriptive logs for errors
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 00:55:51 +0000 (02:55 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Tue, 21 Feb 2017 23:00:26 +0000 (01:00 +0200)
src/plugins_d.c
src/rrddim.c
src/rrdpush.c

index c7a3dac7e16d058c91802d34e142899eb2b2d882..dedb3d72963f3db725f88a3c5770cebc9380681a 100644 (file)
@@ -144,7 +144,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             char *value = words[2];
 
             if(unlikely(!dimension || !*dimension)) {
-                error("PLUGINSD: '%s' is requesting a SET on chart '%s', without a dimension. Disabling it.", cd->fullfilename, st->id);
+                error("PLUGINSD: '%s' is requesting a SET on chart '%s' of host '%s', without a dimension. Disabling it.", cd->fullfilename, st->id, host->hostname);
                 enabled = 0;
                 break;
             }
@@ -152,7 +152,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             if(unlikely(!value || !*value)) value = NULL;
 
             if(unlikely(!st)) {
-                error("PLUGINSD: '%s' is requesting a SET on dimension %s with value %s, without a BEGIN. Disabling it.", cd->fullfilename, dimension, value?value:"<nothing>");
+                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);
                 enabled = 0;
                 break;
             }
@@ -166,14 +166,14 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             char *microseconds_txt = words[2];
 
             if(unlikely(!id)) {
-                error("PLUGINSD: '%s' is requesting a BEGIN without a chart id. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting a BEGIN without a chart id for host '%s'. Disabling it.", cd->fullfilename, host->hostname);
                 enabled = 0;
                 break;
             }
 
             st = rrdset_find(host, id);
             if(unlikely(!st)) {
-                error("PLUGINSD: '%s' is requesting a BEGIN on chart '%s', which does not exist. Disabling it.", cd->fullfilename, id);
+                error("PLUGINSD: '%s' is requesting a BEGIN on chart '%s', which does not exist on host '%s'. Disabling it.", cd->fullfilename, id, host->hostname);
                 enabled = 0;
                 break;
             }
@@ -193,7 +193,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
         }
         else if(likely(hash == END_HASH && !strcmp(s, "END"))) {
             if(unlikely(!st)) {
-                error("PLUGINSD: '%s' is requesting an END, without a BEGIN. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting an END, without a BEGIN on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
                 enabled = 0;
                 break;
             }
@@ -210,12 +210,12 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             char *hostname = words[2];
 
             if(unlikely(!guid || !*guid)) {
-                error("PLUGINSD: '%s' is requesting a HOST, without a guid. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting HOST with guid '%s' and hostname '%s', without a guid. Disabling it.", cd->fullfilename, guid?guid:"", hostname?hostname:"");
                 enabled = 0;
                 break;
             }
             if(unlikely(!hostname || !*hostname)) {
-                error("PLUGINSD: '%s' is requesting a HOST, without a hostname. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting HOST with guid '%s' and hostname '%s', without a hostname. Disabling it.", cd->fullfilename, guid?guid:"", hostname?hostname:"");
                 enabled = 0;
                 break;
             }
@@ -249,7 +249,7 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             char *update_every_s = words[9];
 
             if(unlikely(!type || !*type || !id || !*id)) {
-                error("PLUGINSD: '%s' is requesting a CHART, without a type.id. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting a CHART, without a type.id, on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
                 enabled = 0;
                 break;
             }
@@ -294,13 +294,13 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             char *options = words[6];
 
             if(unlikely(!id || !*id)) {
-                error("PLUGINSD: '%s' is requesting a DIMENSION, without an id. Disabling it.", cd->fullfilename);
+                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");
                 enabled = 0;
                 break;
             }
 
             if(unlikely(!st)) {
-                error("PLUGINSD: '%s' is requesting a DIMENSION, without a CHART. Disabling it.", cd->fullfilename);
+                error("PLUGINSD: '%s' is requesting a DIMENSION, without a CHART, on host '%s'. Disabling it.", cd->fullfilename, host->hostname);
                 enabled = 0;
                 break;
             }
@@ -329,7 +329,8 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int
             RRDDIM *rd = rrddim_find(st, id);
             if(unlikely(!rd)) {
                 rd = rrddim_add(st, id, name, multiplier, divisor, rrd_algorithm_id(algorithm));
-                rd->flags = 0x00000000;
+                rrddim_flag_clear(rd, RRDDIM_FLAG_HIDDEN);
+                rrddim_flag_clear(rd, RRDDIM_FLAG_DONT_DETECT_RESETS_OR_OVERFLOWS);
                 if(options && *options) {
                     if(strstr(options, "hidden") != NULL) rrddim_flag_set(rd, RRDDIM_FLAG_HIDDEN);
                     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
             break;
         }
         else {
-            error("PLUGINSD: '%s' is sending command '%s' which is not known by netdata. Disabling it.", cd->fullfilename, s);
+            error("PLUGINSD: '%s' is sending command '%s' which is not known by netdata, for host '%s'. Disabling it.", cd->fullfilename, s, host->hostname);
             enabled = 0;
             break;
         }
index 80a21e08088cca86864ef135a7e8ebe2e945e75d..70ef3742e5640665ffbf4c9d5f7685a3449c6732 100644 (file)
@@ -80,7 +80,6 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
             rd->id = NULL;
             rd->name = NULL;
             rd->cache_filename = NULL;
-            rd->flags = 0x00000000;
             rd->variables = NULL;
             rd->next = NULL;
             rd->rrdset = NULL;
@@ -164,9 +163,7 @@ RRDDIM *rrddim_add(RRDSET *st, const char *id, const char *name, collected_numbe
 
     // prevent incremental calculation spikes
     rd->counter = 0;
-
-    rrddim_flag_clear(rd, RRDDIM_FLAG_UPDATED);
-    rrddim_flag_clear(rd, RRDDIM_FLAG_EXPOSED);
+    rd->flags = 0x00000000;
 
     rd->calculated_value = 0;
     rd->last_calculated_value = 0;
index c68d0e4f343063df0f07de98639e24cea2d52db9..58c77f940afad348bae229389c14fdf97334dadc 100644 (file)
@@ -17,16 +17,20 @@ static inline void rrdpush_unlock() {
     pthread_mutex_unlock(&rrdpush_mutex);
 }
 
-static inline int need_to_send_chart_definitions(RRDSET *st) {
+static inline int need_to_send_chart_definition(RRDSET *st) {
     RRDDIM *rd;
     rrddim_foreach_read(rd, st)
-        if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED) && !rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
+        if(!rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
             return 1;
 
+
+    // fprintf(stderr, "NOT Sending CHART '%s' '%s'\n", st->id, st->name);
     return 0;
 }
 
-static inline void send_chart_definitions(RRDSET *st) {
+static inline void send_chart_definition(RRDSET *st) {
+    // fprintf(stderr, "Sending CHART '%s' '%s'\n", st->id, st->name);
+
     buffer_sprintf(rrdpush_buffer, "CHART '%s' '%s' '%s' '%s' '%s' '%s' '%s' %ld %d\n"
                 , st->id
                 , st->name
@@ -59,7 +63,7 @@ static inline void send_chart_metrics(RRDSET *st) {
 
     RRDDIM *rd;
     rrddim_foreach_read(rd, st) {
-        if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED))
+        if(rrddim_flag_check(rd, RRDDIM_FLAG_UPDATED) && rrddim_flag_check(rd, RRDDIM_FLAG_EXPOSED))
             buffer_sprintf(rrdpush_buffer, "SET %s = " COLLECTED_NUMBER_FORMAT "\n"
                        , rd->id
                        , rd->collected_value
@@ -106,8 +110,8 @@ void rrdset_done_push(RRDSET *st) {
         last_host = st->rrdhost;
     }
 
-    if(need_to_send_chart_definitions(st))
-        send_chart_definitions(st);
+    if(need_to_send_chart_definition(st))
+        send_chart_definition(st);
 
     send_chart_metrics(st);
 
@@ -154,12 +158,6 @@ void *central_netdata_push_thread(void *ptr) {
     ifd = &fds[0];
     ofd = &fds[1];
 
-    ifd->fd = rrdpush_pipe[PIPE_READ];
-    ifd->events = POLLIN;
-    ofd->events = POLLOUT;
-
-    nfds_t fdmax = 2;
-
     for(;;) {
         if(netdata_exit) break;
 
@@ -215,9 +213,15 @@ void *central_netdata_push_thread(void *ptr) {
             sent_connection = 0;
         }
 
+        ifd->fd = rrdpush_pipe[PIPE_READ];
+        ifd->events = POLLIN;
         ifd->revents = 0;
-        ofd->revents = 0;
+
         ofd->fd = sock;
+        ofd->events = POLLOUT;
+        ofd->revents = 0;
+
+        nfds_t fdmax = 2;
 
         if(begin < buffer_strlen(rrdpush_buffer))
             ofd->events = POLLOUT;
@@ -248,6 +252,8 @@ void *central_netdata_push_thread(void *ptr) {
         }
 
         if(ofd->revents & POLLOUT && begin < buffer_strlen(rrdpush_buffer)) {
+            // info("PUSH: send buffer is ready, sending %zu bytes starting at %zu", buffer_strlen(rrdpush_buffer) - begin, begin);
+
             // fprintf(stderr, "PUSH BEGIN\n");
             // fwrite(&rrdpush_buffer->buffer[begin], 1, buffer_strlen(rrdpush_buffer) - begin, stderr);
             // fprintf(stderr, "\nPUSH END\n");