]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_net_dev.c
fix numa plugin to work only on the expected values; fixes #1868
[netdata.git] / src / proc_net_dev.c
index f2c575f073fb7617e36b5aaa407e8796091e5472..9b942326240baf710e9848d705b1635c3c8bcf92 100644 (file)
@@ -117,15 +117,15 @@ int do_proc_net_dev(int update_every, usec_t dt) {
     static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_drops = -1, do_fifo = -1, do_compressed = -1, do_events = -1;
 
     if(unlikely(enable_new_interfaces == -1)) {
-        enable_new_interfaces = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "enable new interfaces detected at runtime", CONFIG_ONDEMAND_ONDEMAND);
+        enable_new_interfaces = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "enable new interfaces detected at runtime", CONFIG_BOOLEAN_AUTO);
 
-        do_bandwidth    = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "bandwidth for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_packets      = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "packets for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_errors       = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "errors for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_drops        = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "drops for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_fifo         = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "fifo for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_compressed   = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
-        do_events       = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", CONFIG_ONDEMAND_ONDEMAND);
+        do_bandwidth    = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "bandwidth for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_packets      = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "packets for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_errors       = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "errors for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_drops        = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "drops for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_fifo         = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "fifo for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_compressed   = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", CONFIG_BOOLEAN_AUTO);
+        do_events       = config_get_boolean_ondemand("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", CONFIG_BOOLEAN_AUTO);
 
         disabled_list = simple_pattern_create(
                 config_get("plugin:proc:/proc/net/dev", "disable by default interfaces matching", "lo fireqos* *-ifb")
@@ -164,7 +164,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
             snprintfz(var_name, 512, "plugin:proc:/proc/net/dev:%s", d->name);
             d->enabled = config_get_boolean_ondemand(var_name, "enabled", d->enabled);
 
-            if(d->enabled == CONFIG_ONDEMAND_NO)
+            if(d->enabled == CONFIG_BOOLEAN_NO)
                 continue;
 
             d->do_bandwidth  = config_get_boolean_ondemand(var_name, "bandwidth", do_bandwidth);
@@ -179,38 +179,38 @@ int do_proc_net_dev(int update_every, usec_t dt) {
         if(unlikely(!d->enabled))
             continue;
 
-        if(likely(d->do_bandwidth != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_bandwidth != CONFIG_BOOLEAN_NO)) {
             d->rbytes      = str2kernel_uint_t(procfile_lineword(ff, l, 1));
             d->tbytes      = str2kernel_uint_t(procfile_lineword(ff, l, 9));
         }
 
-        if(likely(d->do_packets != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_packets != CONFIG_BOOLEAN_NO)) {
             d->rpackets    = str2kernel_uint_t(procfile_lineword(ff, l, 2));
             d->rmulticast  = str2kernel_uint_t(procfile_lineword(ff, l, 8));
             d->tpackets    = str2kernel_uint_t(procfile_lineword(ff, l, 10));
         }
 
-        if(likely(d->do_errors != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_errors != CONFIG_BOOLEAN_NO)) {
             d->rerrors     = str2kernel_uint_t(procfile_lineword(ff, l, 3));
             d->terrors     = str2kernel_uint_t(procfile_lineword(ff, l, 11));
         }
 
-        if(likely(d->do_drops != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_drops != CONFIG_BOOLEAN_NO)) {
             d->rdrops      = str2kernel_uint_t(procfile_lineword(ff, l, 4));
             d->tdrops      = str2kernel_uint_t(procfile_lineword(ff, l, 12));
         }
 
-        if(likely(d->do_fifo != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_fifo != CONFIG_BOOLEAN_NO)) {
             d->rfifo       = str2kernel_uint_t(procfile_lineword(ff, l, 5));
             d->tfifo       = str2kernel_uint_t(procfile_lineword(ff, l, 13));
         }
 
-        if(likely(d->do_compressed != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_compressed != CONFIG_BOOLEAN_NO)) {
             d->rcompressed = str2kernel_uint_t(procfile_lineword(ff, l, 7));
             d->tcompressed = str2kernel_uint_t(procfile_lineword(ff, l, 16));
         }
 
-        if(likely(d->do_events != CONFIG_ONDEMAND_NO)) {
+        if(likely(d->do_events != CONFIG_BOOLEAN_NO)) {
             d->rframe      = str2kernel_uint_t(procfile_lineword(ff, l, 6));
             d->tcollisions = str2kernel_uint_t(procfile_lineword(ff, l, 14));
             d->tcarrier    = str2kernel_uint_t(procfile_lineword(ff, l, 15));
@@ -218,15 +218,16 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_bandwidth == CONFIG_ONDEMAND_ONDEMAND && (d->rbytes || d->tbytes))))
-            d->do_bandwidth = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_bandwidth == CONFIG_BOOLEAN_AUTO && (d->rbytes || d->tbytes))))
+            d->do_bandwidth = CONFIG_BOOLEAN_YES;
 
-        if(d->do_bandwidth == CONFIG_ONDEMAND_YES) {
+        if(d->do_bandwidth == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_bandwidth)) {
                 d->st_bandwidth = rrdset_find_bytype_localhost("net", d->name);
 
                 if(!d->st_bandwidth)
-                    d->st_bandwidth = rrdset_create("net", d->name, NULL, d->name, "net.net", "Bandwidth", "kilobits/s", 7000, update_every, RRDSET_TYPE_AREA);
+                    d->st_bandwidth = rrdset_create_localhost("net", d->name, NULL, d->name, "net.net", "Bandwidth"
+                                                              , "kilobits/s", 7000, update_every, RRDSET_TYPE_AREA);
 
                 d->rd_rbytes = rrddim_add(d->st_bandwidth, "received", NULL, 8, 1024, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tbytes = rrddim_add(d->st_bandwidth, "sent", NULL, -8, 1024, RRD_ALGORITHM_INCREMENTAL);
@@ -240,17 +241,18 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_packets == CONFIG_ONDEMAND_ONDEMAND && (d->rpackets || d->tpackets || d->rmulticast))))
-            d->do_packets = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_packets == CONFIG_BOOLEAN_AUTO && (d->rpackets || d->tpackets || d->rmulticast))))
+            d->do_packets = CONFIG_BOOLEAN_YES;
 
-        if(d->do_packets == CONFIG_ONDEMAND_YES) {
+        if(d->do_packets == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_packets)) {
                 d->st_packets = rrdset_find_bytype_localhost("net_packets", d->name);
 
                 if(!d->st_packets)
-                    d->st_packets = rrdset_create("net_packets", d->name, NULL, d->name, "net.packets", "Packets", "packets/s", 7001, update_every, RRDSET_TYPE_LINE);
-
-                d->st_packets->isdetail = 1;
+                    d->st_packets = rrdset_create_localhost("net_packets", d->name, NULL, d->name, "net.packets"
+                                                            , "Packets", "packets/s", 7001, update_every
+                                                            , RRDSET_TYPE_LINE);
+                rrdset_flag_set(d->st_packets, RRDSET_FLAG_DETAIL);
 
                 d->rd_rpackets = rrddim_add(d->st_packets, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tpackets = rrddim_add(d->st_packets, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -266,17 +268,19 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_errors == CONFIG_ONDEMAND_ONDEMAND && (d->rerrors || d->terrors))))
-            d->do_errors = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_errors == CONFIG_BOOLEAN_AUTO && (d->rerrors || d->terrors))))
+            d->do_errors = CONFIG_BOOLEAN_YES;
 
-        if(d->do_errors == CONFIG_ONDEMAND_YES) {
+        if(d->do_errors == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_errors)) {
                 d->st_errors = rrdset_find_bytype_localhost("net_errors", d->name);
 
                 if(!d->st_errors)
-                    d->st_errors = rrdset_create("net_errors", d->name, NULL, d->name, "net.errors", "Interface Errors", "errors/s", 7002, update_every, RRDSET_TYPE_LINE);
+                    d->st_errors = rrdset_create_localhost("net_errors", d->name, NULL, d->name, "net.errors"
+                                                           , "Interface Errors", "errors/s", 7002, update_every
+                                                           , RRDSET_TYPE_LINE);
 
-                d->st_errors->isdetail = 1;
+                rrdset_flag_set(d->st_errors, RRDSET_FLAG_DETAIL);
 
                 d->rd_rerrors = rrddim_add(d->st_errors, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_terrors = rrddim_add(d->st_errors, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -290,17 +294,19 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_drops == CONFIG_ONDEMAND_ONDEMAND && (d->rdrops || d->tdrops))))
-            d->do_drops = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_drops == CONFIG_BOOLEAN_AUTO && (d->rdrops || d->tdrops))))
+            d->do_drops = CONFIG_BOOLEAN_YES;
 
-        if(d->do_drops == CONFIG_ONDEMAND_YES) {
+        if(d->do_drops == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_drops)) {
                 d->st_drops = rrdset_find_bytype_localhost("net_drops", d->name);
 
                 if(!d->st_drops)
-                    d->st_drops = rrdset_create("net_drops", d->name, NULL, d->name, "net.drops", "Interface Drops", "drops/s", 7003, update_every, RRDSET_TYPE_LINE);
+                    d->st_drops = rrdset_create_localhost("net_drops", d->name, NULL, d->name, "net.drops"
+                                                          , "Interface Drops", "drops/s", 7003, update_every
+                                                          , RRDSET_TYPE_LINE);
 
-                d->st_drops->isdetail = 1;
+                rrdset_flag_set(d->st_drops, RRDSET_FLAG_DETAIL);
 
                 d->rd_rdrops = rrddim_add(d->st_drops, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tdrops = rrddim_add(d->st_drops, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -314,17 +320,19 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_fifo == CONFIG_ONDEMAND_ONDEMAND && (d->rfifo || d->tfifo))))
-            d->do_fifo = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_fifo == CONFIG_BOOLEAN_AUTO && (d->rfifo || d->tfifo))))
+            d->do_fifo = CONFIG_BOOLEAN_YES;
 
-        if(d->do_fifo == CONFIG_ONDEMAND_YES) {
+        if(d->do_fifo == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_fifo)) {
                 d->st_fifo = rrdset_find_bytype_localhost("net_fifo", d->name);
 
                 if(!d->st_fifo)
-                    d->st_fifo = rrdset_create("net_fifo", d->name, NULL, d->name, "net.fifo", "Interface FIFO Buffer Errors", "errors", 7004, update_every, RRDSET_TYPE_LINE);
+                    d->st_fifo = rrdset_create_localhost("net_fifo", d->name, NULL, d->name, "net.fifo"
+                                                         , "Interface FIFO Buffer Errors", "errors", 7004, update_every
+                                                         , RRDSET_TYPE_LINE);
 
-                d->st_fifo->isdetail = 1;
+                rrdset_flag_set(d->st_fifo, RRDSET_FLAG_DETAIL);
 
                 d->rd_rfifo = rrddim_add(d->st_fifo, "receive", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tfifo = rrddim_add(d->st_fifo, "transmit", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -338,16 +346,18 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_compressed == CONFIG_ONDEMAND_ONDEMAND && (d->rcompressed || d->tcompressed))))
-            d->do_compressed = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_compressed == CONFIG_BOOLEAN_AUTO && (d->rcompressed || d->tcompressed))))
+            d->do_compressed = CONFIG_BOOLEAN_YES;
 
-        if(d->do_compressed == CONFIG_ONDEMAND_YES) {
+        if(d->do_compressed == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_compressed)) {
                 d->st_compressed = rrdset_find_bytype_localhost("net_compressed", d->name);
                 if(!d->st_compressed)
-                    d->st_compressed = rrdset_create("net_compressed", d->name, NULL, d->name, "net.compressed", "Compressed Packets", "packets/s", 7005, update_every, RRDSET_TYPE_LINE);
+                    d->st_compressed = rrdset_create_localhost("net_compressed", d->name, NULL, d->name
+                                                               , "net.compressed", "Compressed Packets", "packets/s"
+                                                               , 7005, update_every, RRDSET_TYPE_LINE);
 
-                d->st_compressed->isdetail = 1;
+                rrdset_flag_set(d->st_compressed, RRDSET_FLAG_DETAIL);
 
                 d->rd_rcompressed = rrddim_add(d->st_compressed, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tcompressed = rrddim_add(d->st_compressed, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
@@ -361,16 +371,18 @@ int do_proc_net_dev(int update_every, usec_t dt) {
 
         // --------------------------------------------------------------------
 
-        if(unlikely((d->do_events == CONFIG_ONDEMAND_ONDEMAND && (d->rframe || d->tcollisions || d->tcarrier))))
-            d->do_events = CONFIG_ONDEMAND_YES;
+        if(unlikely((d->do_events == CONFIG_BOOLEAN_AUTO && (d->rframe || d->tcollisions || d->tcarrier))))
+            d->do_events = CONFIG_BOOLEAN_YES;
 
-        if(d->do_events == CONFIG_ONDEMAND_YES) {
+        if(d->do_events == CONFIG_BOOLEAN_YES) {
             if(unlikely(!d->st_events)) {
                 d->st_events = rrdset_find_bytype_localhost("net_events", d->name);
                 if(!d->st_events)
-                    d->st_events = rrdset_create("net_events", d->name, NULL, d->name, "net.events", "Network Interface Events", "events/s", 7006, update_every, RRDSET_TYPE_LINE);
+                    d->st_events = rrdset_create_localhost("net_events", d->name, NULL, d->name, "net.events"
+                                                           , "Network Interface Events", "events/s", 7006, update_every
+                                                           , RRDSET_TYPE_LINE);
 
-                d->st_events->isdetail = 1;
+                rrdset_flag_set(d->st_events, RRDSET_FLAG_DETAIL);
 
                 d->rd_rframe      = rrddim_add(d->st_events, "frames", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
                 d->rd_tcollisions = rrddim_add(d->st_events, "collisions", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);