]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_net_dev.c
reverted strcmp()
[netdata.git] / src / proc_net_dev.c
index 6813d5e56d00608e075c4d987065550d300be510..82661abd439d8cc03f9abdbdcaacadd809702026 100644 (file)
@@ -112,7 +112,7 @@ static struct netdev *get_netdev(const char *name) {
 int do_proc_net_dev(int update_every, usec_t dt) {
     (void)dt;
 
-    static NETDATA_SIMPLE_PATTERN *disabled_list = NULL;
+    static SIMPLE_PATTERN *disabled_list = NULL;
     static procfile *ff = NULL;
     static int enable_new_interfaces = -1;
     static int do_bandwidth = -1, do_packets = -1, do_errors = -1, do_drops = -1, do_fifo = -1, do_compressed = -1, do_events = -1;
@@ -128,7 +128,9 @@ int do_proc_net_dev(int update_every, usec_t dt) {
         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);
 
-        disabled_list = netdata_simple_pattern_list_create(config_get("plugin:proc:/proc/net/dev", "disable by default interfaces matching", "lo fireqos* *-ifb"), NETDATA_SIMPLE_PATTERN_MODE_EXACT);
+        disabled_list = simple_pattern_create(
+                config_get("plugin:proc:/proc/net/dev", "disable by default interfaces matching", "lo fireqos* *-ifb")
+                , SIMPLE_PATTERN_EXACT);
     }
 
     if(unlikely(!ff)) {
@@ -141,7 +143,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
     ff = procfile_readall(ff);
     if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
 
-    uint32_t lines = procfile_lines(ff), l;
+    size_t lines = procfile_lines(ff), l;
     for(l = 2; l < lines ;l++) {
         // require 17 words on each line
         if(unlikely(procfile_linewords(ff, l) < 17)) continue;
@@ -157,7 +159,7 @@ int do_proc_net_dev(int update_every, usec_t dt) {
             d->enabled = enable_new_interfaces;
 
             if(d->enabled)
-                d->enabled = !netdata_simple_pattern_list_matches(disabled_list, d->name);
+                d->enabled = !simple_pattern_matches(disabled_list, d->name);
 
             char var_name[512 + 1];
             snprintfz(var_name, 512, "plugin:proc:/proc/net/dev:%s", d->name);
@@ -178,23 +180,23 @@ int do_proc_net_dev(int update_every, usec_t dt) {
         if(unlikely(!d->enabled))
             continue;
 
-        d->rbytes      = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
-        d->rpackets    = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
-        d->rerrors     = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
-        d->rdrops      = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
-        d->rfifo       = strtoull(procfile_lineword(ff, l, 5), NULL, 10);
-        d->rframe      = strtoull(procfile_lineword(ff, l, 6), NULL, 10);
-        d->rcompressed = strtoull(procfile_lineword(ff, l, 7), NULL, 10);
-        d->rmulticast  = strtoull(procfile_lineword(ff, l, 8), NULL, 10);
-
-        d->tbytes      = strtoull(procfile_lineword(ff, l, 9), NULL, 10);
-        d->tpackets    = strtoull(procfile_lineword(ff, l, 10), NULL, 10);
-        d->terrors     = strtoull(procfile_lineword(ff, l, 11), NULL, 10);
-        d->tdrops      = strtoull(procfile_lineword(ff, l, 12), NULL, 10);
-        d->tfifo       = strtoull(procfile_lineword(ff, l, 13), NULL, 10);
-        d->tcollisions = strtoull(procfile_lineword(ff, l, 14), NULL, 10);
-        d->tcarrier    = strtoull(procfile_lineword(ff, l, 15), NULL, 10);
-        d->tcompressed = strtoull(procfile_lineword(ff, l, 16), NULL, 10);
+        d->rbytes      = str2ull(procfile_lineword(ff, l, 1));
+        d->rpackets    = str2ull(procfile_lineword(ff, l, 2));
+        d->rerrors     = str2ull(procfile_lineword(ff, l, 3));
+        d->rdrops      = str2ull(procfile_lineword(ff, l, 4));
+        d->rfifo       = str2ull(procfile_lineword(ff, l, 5));
+        d->rframe      = str2ull(procfile_lineword(ff, l, 6));
+        d->rcompressed = str2ull(procfile_lineword(ff, l, 7));
+        d->rmulticast  = str2ull(procfile_lineword(ff, l, 8));
+
+        d->tbytes      = str2ull(procfile_lineword(ff, l, 9));
+        d->tpackets    = str2ull(procfile_lineword(ff, l, 10));
+        d->terrors     = str2ull(procfile_lineword(ff, l, 11));
+        d->tdrops      = str2ull(procfile_lineword(ff, l, 12));
+        d->tfifo       = str2ull(procfile_lineword(ff, l, 13));
+        d->tcollisions = str2ull(procfile_lineword(ff, l, 14));
+        d->tcarrier    = str2ull(procfile_lineword(ff, l, 15));
+        d->tcompressed = str2ull(procfile_lineword(ff, l, 16));
 
         // --------------------------------------------------------------------