]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_net_rpc_nfs.c
dns_query_time plugin: replace "." with "_" in dimensions
[netdata.git] / src / proc_net_rpc_nfs.c
index 86e2f70c0d23a74f8f1e1a9edf2ab2281ef93663..0df91963560d1b0a91c96801e92c21ffe19953e4 100644 (file)
@@ -127,7 +127,7 @@ struct nfs_procs nfs_proc4_values[] = {
     { "", 0ULL, 0 }
 };
 
-int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
+int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
     (void)dt;
 
     static procfile *ff = NULL;
@@ -136,7 +136,7 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
 
     if(!ff) {
         char filename[FILENAME_MAX + 1];
-        snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/rpc/nfs");
+        snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/rpc/nfs");
         ff = procfile_open(config_get("plugin:proc:/proc/net/rpc/nfs", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
     }
     if(!ff) return 1;
@@ -151,35 +151,35 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
     if(do_proc4 == -1) do_proc4 = config_get_boolean("plugin:proc:/proc/net/rpc/nfs", "NFS v4 procedures", 1);
 
     // if they are enabled, reset them to 1
-    // later we do them =2 to avoid doing strcmp for all lines
+    // later we do them =2 to avoid doing strcmp() for all lines
     if(do_net) do_net = 1;
     if(do_rpc) do_rpc = 1;
     if(do_proc2) do_proc2 = 1;
     if(do_proc3) do_proc3 = 1;
     if(do_proc4) do_proc4 = 1;
 
-    uint32_t lines = procfile_lines(ff), l;
+    size_t lines = procfile_lines(ff), l;
 
     char *type;
     unsigned long long net_count = 0, net_udp_count = 0, net_tcp_count = 0, net_tcp_connections = 0;
     unsigned long long rpc_calls = 0, rpc_retransmits = 0, rpc_auth_refresh = 0;
 
     for(l = 0; l < lines ;l++) {
-        uint32_t words = procfile_linewords(ff, l);
+        size_t words = procfile_linewords(ff, l);
         if(!words) continue;
 
         type        = procfile_lineword(ff, l, 0);
 
         if(do_net == 1 && strcmp(type, "net") == 0) {
             if(words < 5) {
-                error("%s line of /proc/net/rpc/nfs has %u words, expected %d", type, words, 5);
+                error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 5);
                 continue;
             }
 
-            net_count = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
-            net_udp_count = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
-            net_tcp_count = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
-            net_tcp_connections = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
+            net_count = str2ull(procfile_lineword(ff, l, 1));
+            net_udp_count = str2ull(procfile_lineword(ff, l, 2));
+            net_tcp_count = str2ull(procfile_lineword(ff, l, 3));
+            net_tcp_connections = str2ull(procfile_lineword(ff, l, 4));
 
             unsigned long long sum = net_count + net_udp_count + net_tcp_count + net_tcp_connections;
             if(sum == 0ULL) do_net = -1;
@@ -187,13 +187,13 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
         }
         else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
             if(words < 4) {
-                error("%s line of /proc/net/rpc/nfs has %u words, expected %d", type, words, 6);
+                error("%s line of /proc/net/rpc/nfs has %zu words, expected %d", type, words, 6);
                 continue;
             }
 
-            rpc_calls = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
-            rpc_retransmits = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
-            rpc_auth_refresh = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
+            rpc_calls = str2ull(procfile_lineword(ff, l, 1));
+            rpc_retransmits = str2ull(procfile_lineword(ff, l, 2));
+            rpc_auth_refresh = str2ull(procfile_lineword(ff, l, 3));
 
             unsigned long long sum = rpc_calls + rpc_retransmits + rpc_auth_refresh;
             if(sum == 0ULL) do_rpc = -1;
@@ -206,7 +206,7 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
             unsigned long long sum = 0;
             unsigned int i, j;
             for(i = 0, j = 2; j < words && nfs_proc2_values[i].name[0] ; i++, j++) {
-                nfs_proc2_values[i].value = strtoull(procfile_lineword(ff, l, j), NULL, 10);
+                nfs_proc2_values[i].value = str2ull(procfile_lineword(ff, l, j));
                 nfs_proc2_values[i].present = 1;
                 sum += nfs_proc2_values[i].value;
             }
@@ -227,7 +227,7 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
             unsigned long long sum = 0;
             unsigned int i, j;
             for(i = 0, j = 2; j < words && nfs_proc3_values[i].name[0] ; i++, j++) {
-                nfs_proc3_values[i].value = strtoull(procfile_lineword(ff, l, j), NULL, 10);
+                nfs_proc3_values[i].value = str2ull(procfile_lineword(ff, l, j));
                 nfs_proc3_values[i].present = 1;
                 sum += nfs_proc3_values[i].value;
             }
@@ -248,7 +248,7 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
             unsigned long long sum = 0;
             unsigned int i, j;
             for(i = 0, j = 2; j < words && nfs_proc4_values[i].name[0] ; i++, j++) {
-                nfs_proc4_values[i].value = strtoull(procfile_lineword(ff, l, j), NULL, 10);
+                nfs_proc4_values[i].value = str2ull(procfile_lineword(ff, l, j));
                 nfs_proc4_values[i].present = 1;
                 sum += nfs_proc4_values[i].value;
             }
@@ -269,13 +269,14 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
     // --------------------------------------------------------------------
 
     if(do_net == 2) {
-        st = rrdset_find_bytype("nfs", "net");
+        st = rrdset_find_bytype_localhost("nfs", "net");
         if(!st) {
-            st = rrdset_create("nfs", "net", NULL, "network", NULL, "NFS Client Network", "operations/s", 5007, update_every, RRDSET_TYPE_STACKED);
-            st->isdetail = 1;
+            st = rrdset_create_localhost("nfs", "net", NULL, "network", NULL, "NFS Client Network", "operations/s", 5007
+                                         , update_every, RRDSET_TYPE_STACKED);
+            rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
 
-            rrddim_add(st, "udp", NULL, 1, 1, RRDDIM_INCREMENTAL);
-            rrddim_add(st, "tcp", NULL, 1, 1, RRDDIM_INCREMENTAL);
+            rrddim_add(st, "udp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+            rrddim_add(st, "tcp", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
         }
         else rrdset_next(st);
 
@@ -291,14 +292,15 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
     // --------------------------------------------------------------------
 
     if(do_rpc == 2) {
-        st = rrdset_find_bytype("nfs", "rpc");
+        st = rrdset_find_bytype_localhost("nfs", "rpc");
         if(!st) {
-            st = rrdset_create("nfs", "rpc", NULL, "rpc", NULL, "NFS Client Remote Procedure Calls Statistics", "calls/s", 5008, update_every, RRDSET_TYPE_LINE);
-            st->isdetail = 1;
+            st = rrdset_create_localhost("nfs", "rpc", NULL, "rpc", NULL, "NFS Client Remote Procedure Calls Statistics"
+                                         , "calls/s", 5008, update_every, RRDSET_TYPE_LINE);
+            rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
 
-            rrddim_add(st, "calls", NULL, 1, 1, RRDDIM_INCREMENTAL);
-            rrddim_add(st, "retransmits", NULL, -1, 1, RRDDIM_INCREMENTAL);
-            rrddim_add(st, "auth_refresh", NULL, -1, 1, RRDDIM_INCREMENTAL);
+            rrddim_add(st, "calls", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+            rrddim_add(st, "retransmits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
+            rrddim_add(st, "auth_refresh", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
         }
         else rrdset_next(st);
 
@@ -312,12 +314,13 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
 
     if(do_proc2 == 2) {
         unsigned int i;
-        st = rrdset_find_bytype("nfs", "proc2");
+        st = rrdset_find_bytype_localhost("nfs", "proc2");
         if(!st) {
-            st = rrdset_create("nfs", "proc2", NULL, "nfsv2rpc", NULL, "NFS v2 Client Remote Procedure Calls", "calls/s", 5009, update_every, RRDSET_TYPE_STACKED);
+            st = rrdset_create_localhost("nfs", "proc2", NULL, "nfsv2rpc", NULL, "NFS v2 Client Remote Procedure Calls"
+                                         , "calls/s", 5009, update_every, RRDSET_TYPE_STACKED);
 
             for(i = 0; nfs_proc2_values[i].present ; i++)
-                rrddim_add(st, nfs_proc2_values[i].name, NULL, 1, 1, RRDDIM_INCREMENTAL);
+                rrddim_add(st, nfs_proc2_values[i].name, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
         }
         else rrdset_next(st);
 
@@ -331,12 +334,13 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
 
     if(do_proc3 == 2) {
         unsigned int i;
-        st = rrdset_find_bytype("nfs", "proc3");
+        st = rrdset_find_bytype_localhost("nfs", "proc3");
         if(!st) {
-            st = rrdset_create("nfs", "proc3", NULL, "nfsv3rpc", NULL, "NFS v3 Client Remote Procedure Calls", "calls/s", 5010, update_every, RRDSET_TYPE_STACKED);
+            st = rrdset_create_localhost("nfs", "proc3", NULL, "nfsv3rpc", NULL, "NFS v3 Client Remote Procedure Calls"
+                                         , "calls/s", 5010, update_every, RRDSET_TYPE_STACKED);
 
             for(i = 0; nfs_proc3_values[i].present ; i++)
-                rrddim_add(st, nfs_proc3_values[i].name, NULL, 1, 1, RRDDIM_INCREMENTAL);
+                rrddim_add(st, nfs_proc3_values[i].name, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
         }
         else rrdset_next(st);
 
@@ -350,12 +354,13 @@ int do_proc_net_rpc_nfs(int update_every, unsigned long long dt) {
 
     if(do_proc4 == 2) {
         unsigned int i;
-        st = rrdset_find_bytype("nfs", "proc4");
+        st = rrdset_find_bytype_localhost("nfs", "proc4");
         if(!st) {
-            st = rrdset_create("nfs", "proc4", NULL, "nfsv4rpc", NULL, "NFS v4 Client Remote Procedure Calls", "calls/s", 5011, update_every, RRDSET_TYPE_STACKED);
+            st = rrdset_create_localhost("nfs", "proc4", NULL, "nfsv4rpc", NULL, "NFS v4 Client Remote Procedure Calls"
+                                         , "calls/s", 5011, update_every, RRDSET_TYPE_STACKED);
 
             for(i = 0; nfs_proc4_values[i].present ; i++)
-                rrddim_add(st, nfs_proc4_values[i].name, NULL, 1, 1, RRDDIM_INCREMENTAL);
+                rrddim_add(st, nfs_proc4_values[i].name, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
         }
         else rrdset_next(st);