]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_tc.c
multi-host rrdset and rrdfamily operations
[netdata.git] / src / plugin_tc.c
index 7aef4ab5bc637337068464d66eba4f2cc5cc7473..9ef7cead81db7dee7bccbf2cc5582476118b5f32 100644 (file)
@@ -283,29 +283,31 @@ static inline void tc_device_commit(struct tc_device *d) {
     //
     // so, here we remove the isleaf flag from nodes in the middle
     // and we add the hasparent flag to leaf nodes we found their parent
-    for(c = d->classes; c; c = c->next) {
-        if(unlikely(!c->updated)) continue;
-
-        //debug(D_TC_LOOP, "TC: In device '%s', %s '%s'  has leafid: '%s' and parentid '%s'.",
-        //    d->id,
-        //    c->isqdisc?"qdisc":"class",
-        //    c->id,
-        //    c->leafid?c->leafid:"NULL",
-        //    c->parentid?c->parentid:"NULL");
-
-        // find if c is leaf or not
-        for(x = d->classes; x; x = x->next) {
-            if(unlikely(!x->updated || c == x || !x->parentid)) continue;
-
-            // classes have both parentid and leafid
-            // qdiscs have only parentid
-            // the following works for both (it is an OR)
-
-            if( (c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
-                (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0)) {
-                // debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id);
-                c->isleaf = 0;
-                x->hasparent = 1;
+    if(likely(!d->enabled_all_classes_qdiscs)) {
+        for(c = d->classes; c; c = c->next) {
+            if(unlikely(!c->updated)) continue;
+
+            //debug(D_TC_LOOP, "TC: In device '%s', %s '%s'  has leafid: '%s' and parentid '%s'.",
+            //    d->id,
+            //    c->isqdisc?"qdisc":"class",
+            //    c->id,
+            //    c->leafid?c->leafid:"NULL",
+            //    c->parentid?c->parentid:"NULL");
+
+            // find if c is leaf or not
+            for(x = d->classes; x; x = x->next) {
+                if(unlikely(!x->updated || c == x || !x->parentid)) continue;
+
+                // classes have both parentid and leafid
+                // qdiscs have only parentid
+                // the following works for both (it is an OR)
+
+                if((c->hash == x->parent_hash && strcmp(c->id, x->parentid) == 0) ||
+                   (c->leafid && c->leaf_hash == x->parent_hash && strcmp(c->leafid, x->parentid) == 0)) {
+                    // debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id);
+                    c->isleaf = 0;
+                    x->hasparent = 1;
+                }
             }
         }
     }
@@ -386,7 +388,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             if(unlikely(!c->render)) continue;
 
             if(unlikely(!c->rd_bytes))
-                c->rd_bytes = rrddim_add(d->st_bytes, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_INCREMENTAL);
+                c->rd_bytes = rrddim_add(d->st_bytes, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_ALGORITHM_INCREMENTAL);
             else if(unlikely(c->name_updated))
                 rrddim_set_name(d->st_bytes, c->rd_bytes, c->name);
 
@@ -426,7 +428,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             if(unlikely(!c->render)) continue;
 
             if(unlikely(!c->rd_packets))
-                c->rd_packets = rrddim_add(d->st_packets, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_INCREMENTAL);
+                c->rd_packets = rrddim_add(d->st_packets, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ALGORITHM_INCREMENTAL);
             else if(unlikely(c->name_updated))
                 rrddim_set_name(d->st_packets, c->rd_packets, c->name);
 
@@ -466,7 +468,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             if(unlikely(!c->render)) continue;
 
             if(unlikely(!c->rd_dropped))
-                c->rd_dropped = rrddim_add(d->st_dropped, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_INCREMENTAL);
+                c->rd_dropped = rrddim_add(d->st_dropped, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ALGORITHM_INCREMENTAL);
             else if(unlikely(c->name_updated))
                 rrddim_set_name(d->st_dropped, c->rd_dropped, c->name);
 
@@ -506,7 +508,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             if(unlikely(!c->render)) continue;
 
             if(unlikely(!c->rd_tokens)) {
-                c->rd_tokens = rrddim_add(d->st_tokens, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ABSOLUTE);
+                c->rd_tokens = rrddim_add(d->st_tokens, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ALGORITHM_ABSOLUTE);
             }
             else if(unlikely(c->name_updated))
                 rrddim_set_name(d->st_tokens, c->rd_tokens, c->name);
@@ -548,7 +550,7 @@ static inline void tc_device_commit(struct tc_device *d) {
             if(unlikely(!c->render)) continue;
 
             if(unlikely(!c->rd_ctokens))
-                c->rd_ctokens = rrddim_add(d->st_ctokens, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ABSOLUTE);
+                c->rd_ctokens = rrddim_add(d->st_ctokens, c->id, c->name?c->name:c->id, 1, 1, RRDDIM_ALGORITHM_ABSOLUTE);
             else if(unlikely(c->name_updated))
                 rrddim_set_name(d->st_ctokens, c->rd_ctokens, c->name);
 
@@ -780,7 +782,7 @@ void *tc_main(void *ptr) {
 #endif
     uint32_t first_hash;
 
-    snprintfz(buffer, TC_LINE_MAX, "%s/tc-qos-helper.sh", config_get("plugins", "plugins directory", PLUGINS_DIR));
+    snprintfz(buffer, TC_LINE_MAX, "%s/tc-qos-helper.sh", netdata_configured_plugins_dir);
     char *tc_script = config_get("plugin:tc", "script to run to get tc values", buffer);
     
     for(;1;) {
@@ -972,11 +974,11 @@ void *tc_main(void *ptr) {
                 // debug(D_TC_LOOP, "WORKTIME line '%s' '%s'", words[1], words[2]);
                 getrusage(RUSAGE_THREAD, &thread);
 
-                if(unlikely(!stcpu)) stcpu = rrdset_find("netdata.plugin_tc_cpu");
+                if(unlikely(!stcpu)) stcpu = rrdset_find_localhost("netdata.plugin_tc_cpu");
                 if(unlikely(!stcpu)) {
                     stcpu = rrdset_create("netdata", "plugin_tc_cpu", NULL, "tc.helper", NULL, "NetData TC CPU usage", "milliseconds/s", 135000, rrd_update_every, RRDSET_TYPE_STACKED);
-                    rrddim_add(stcpu, "user",  NULL,  1, 1000, RRDDIM_INCREMENTAL);
-                    rrddim_add(stcpu, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);
+                    rrddim_add(stcpu, "user",  NULL,  1, 1000, RRDDIM_ALGORITHM_INCREMENTAL);
+                    rrddim_add(stcpu, "system", NULL, 1, 1000, RRDDIM_ALGORITHM_INCREMENTAL);
                 }
                 else rrdset_next(stcpu);
 
@@ -984,10 +986,10 @@ void *tc_main(void *ptr) {
                 rrddim_set(stcpu, "system", thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec);
                 rrdset_done(stcpu);
 
-                if(unlikely(!sttime)) stcpu = rrdset_find("netdata.plugin_tc_time");
+                if(unlikely(!sttime)) stcpu = rrdset_find_localhost("netdata.plugin_tc_time");
                 if(unlikely(!sttime)) {
                     sttime = rrdset_create("netdata", "plugin_tc_time", NULL, "tc.helper", NULL, "NetData TC script execution", "milliseconds/run", 135001, rrd_update_every, RRDSET_TYPE_AREA);
-                    rrddim_add(sttime, "run_time",  "run time",  1, 1, RRDDIM_ABSOLUTE);
+                    rrddim_add(sttime, "run_time",  "run time",  1, 1, RRDDIM_ALGORITHM_ABSOLUTE);
                 }
                 else rrdset_next(sttime);