]> arthur.barton.de Git - netdata.git/blob - src/proc_net_rpc_nfsd.c
added config options for all /proc and /sys filenames monitored required for #10
[netdata.git] / src / proc_net_rpc_nfsd.c
1 #include <inttypes.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5
6 #include "common.h"
7 #include "log.h"
8 #include "config.h"
9 #include "procfile.h"
10 #include "rrd.h"
11 #include "plugin_proc.h"
12
13 struct nfsd_procs {
14         char name[30];
15         unsigned long long proc2;
16         unsigned long long proc3;
17         unsigned long long proc4;
18         int present2;
19         int present3;
20         int present4;
21 };
22
23 struct nfsd_procs nfsd_proc_values[] = {
24         { "null", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
25         { "getattr", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
26         { "setattr", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
27         { "lookup", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
28         { "access", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
29         { "readlink", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
30         { "read", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
31         { "write", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
32         { "create", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
33         { "mkdir", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
34         { "symlink", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
35         { "mknod", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
36         { "remove", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
37         { "rmdir", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
38         { "rename", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
39         { "link", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
40         { "readdir", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
41         { "readdirplus", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
42         { "fsstat", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
43         { "fsinfo", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
44         { "pathconf", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
45         { "commit", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
46         { "", 0ULL, 0ULL, 0ULL, 0, 0, 0 },
47 };
48
49 struct nfsd4_ops {
50         char name[30];
51         unsigned long long value;
52         int present;
53 };
54
55 struct nfsd4_ops nfsd4_ops_values[] = {
56         { "access", 0ULL, 0},
57         { "close", 0ULL, 0},
58         { "commit", 0ULL, 0},
59         { "create", 0ULL, 0},
60         { "delegpurge", 0ULL, 0},
61         { "delegreturn", 0ULL, 0},
62         { "getattr", 0ULL, 0},
63         { "getfh", 0ULL, 0},
64         { "link", 0ULL, 0},
65         { "lock", 0ULL, 0},
66         { "lockt", 0ULL, 0},
67         { "locku", 0ULL, 0},
68         { "lookup", 0ULL, 0},
69         { "lookupp", 0ULL, 0},
70         { "nverify", 0ULL, 0},
71         { "open", 0ULL, 0},
72         { "openattr", 0ULL, 0},
73         { "open_confirm", 0ULL, 0},
74         { "open_downgrade", 0ULL, 0},
75         { "putfh", 0ULL, 0},
76         { "putpubfh", 0ULL, 0},
77         { "putrootfh", 0ULL, 0},
78         { "read", 0ULL, 0},
79         { "readdir", 0ULL, 0},
80         { "readlink", 0ULL, 0},
81         { "remove", 0ULL, 0},
82         { "rename", 0ULL, 0},
83         { "renew", 0ULL, 0},
84         { "restorefh", 0ULL, 0},
85         { "savefh", 0ULL, 0},
86         { "secinfo", 0ULL, 0},
87         { "setattr", 0ULL, 0},
88         { "setclientid", 0ULL, 0},
89         { "setclientid_confirm", 0ULL, 0},
90         { "verify", 0ULL, 0},
91         { "write", 0ULL, 0},
92         { "release_lockowner", 0ULL, 0},
93
94         /* nfs41 */
95         { "backchannel_ctl", 0ULL, 0},
96         { "bind_conn_to_session", 0ULL, 0},
97         { "exchange_id", 0ULL, 0},
98         { "create_session", 0ULL, 0},
99         { "destroy_session", 0ULL, 0},
100         { "free_stateid", 0ULL, 0},
101         { "get_dir_delegation", 0ULL, 0},
102         { "getdeviceinfo", 0ULL, 0},
103         { "getdevicelist", 0ULL, 0},
104         { "layoutcommit", 0ULL, 0},
105         { "layoutget", 0ULL, 0},
106         { "layoutreturn", 0ULL, 0},
107         { "secinfo_no_name", 0ULL, 0},
108         { "sequence", 0ULL, 0},
109         { "set_ssv", 0ULL, 0},
110         { "test_stateid", 0ULL, 0},
111         { "want_delegation", 0ULL, 0},
112         { "destroy_clientid", 0ULL, 0},
113         { "reclaim_complete", 0ULL, 0},
114
115         /* nfs42 */
116         { "allocate", 0ULL, 0},
117         { "copy", 0ULL, 0},
118         { "copy_notify", 0ULL, 0},
119         { "deallocate", 0ULL, 0},
120         { "io_advise", 0ULL, 0},
121         { "layouterror", 0ULL, 0},
122         { "layoutstats", 0ULL, 0},
123         { "offload_cancel", 0ULL, 0},
124         { "offload_status", 0ULL, 0},
125         { "read_plus", 0ULL, 0},
126         { "seek", 0ULL, 0},
127         { "write_same", 0ULL, 0},
128
129         /* termination */
130         { "", 0ULL, 0 }
131 };
132
133
134 int do_proc_net_rpc_nfsd(int update_every, unsigned long long dt) {
135         static procfile *ff = NULL;
136         static int do_rc = -1, do_fh = -1, do_io = -1, do_th = -1, do_ra = -1, do_net = -1, do_rpc = -1, do_proc2 = -1, do_proc3 = -1, do_proc4 = -1, do_proc4ops = -1;
137         static int ra_warning = 0, th_warning = 0, proc2_warning = 0, proc3_warning = 0, proc4_warning = 0, proc4ops_warning = 0;
138
139         if(dt) {};
140
141         if(!ff) ff = procfile_open(config_get("plugin:proc:/proc/net/rpc/nfsd", "filename to monitor", "/proc/net/rpc/nfsd"), " \t", PROCFILE_FLAG_DEFAULT);
142         if(!ff) return 1;
143
144         ff = procfile_readall(ff);
145         if(!ff) return 0; // we return 0, so that we will retry to open it next time
146
147         if(do_rc == -1) do_rc = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "read cache", 1);
148         if(do_fh == -1) do_fh = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "file handles", 1);
149         if(do_io == -1) do_io = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "I/O", 1);
150         if(do_th == -1) do_th = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "threads", 1);
151         if(do_ra == -1) do_ra = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "read ahead", 1);
152         if(do_net == -1) do_net = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "network", 1);
153         if(do_rpc == -1) do_rpc = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "rpc", 1);
154         if(do_proc2 == -1) do_proc2 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v2 procedures", 1);
155         if(do_proc3 == -1) do_proc3 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v3 procedures", 1);
156         if(do_proc4 == -1) do_proc4 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 procedures", 1);
157         if(do_proc4ops == -1) do_proc4ops = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 operations", 1);
158
159         // if they are enabled, reset them to 1
160         // later we do them =2 to avoid doing strcmp for all lines
161         if(do_rc) do_rc = 1;
162         if(do_fh) do_fh = 1;
163         if(do_io) do_io = 1;
164         if(do_th) do_th = 1;
165         if(do_ra) do_ra = 1;
166         if(do_net) do_net = 1;
167         if(do_rpc) do_rpc = 1;
168         if(do_proc2) do_proc2 = 1;
169         if(do_proc3) do_proc3 = 1;
170         if(do_proc4) do_proc4 = 1;
171         if(do_proc4ops) do_proc4ops = 1;
172
173         uint32_t lines = procfile_lines(ff), l;
174         uint32_t words;
175
176         char *type;
177         unsigned long long rc_hits = 0, rc_misses = 0, rc_nocache = 0;
178         unsigned long long fh_stale = 0, fh_total_lookups = 0, fh_anonymous_lookups = 0, fh_dir_not_in_dcache = 0, fh_non_dir_not_in_dcache = 0;
179         unsigned long long io_read = 0, io_write = 0;
180         unsigned long long th_threads = 0, th_fullcnt = 0, th_hist10 = 0, th_hist20 = 0, th_hist30 = 0, th_hist40 = 0, th_hist50 = 0, th_hist60 = 0, th_hist70 = 0, th_hist80 = 0, th_hist90 = 0, th_hist100 = 0;
181         unsigned long long ra_size = 0, ra_hist10 = 0, ra_hist20 = 0, ra_hist30 = 0, ra_hist40 = 0, ra_hist50 = 0, ra_hist60 = 0, ra_hist70 = 0, ra_hist80 = 0, ra_hist90 = 0, ra_hist100 = 0, ra_none = 0;
182         unsigned long long net_count = 0, net_udp_count = 0, net_tcp_count = 0, net_tcp_connections = 0;
183         unsigned long long rpc_count = 0, rpc_bad_format = 0, rpc_bad_auth = 0, rpc_bad_client = 0;
184
185         for(l = 0; l < lines ;l++) {
186                 words = procfile_linewords(ff, l);
187                 if(!words) continue;
188
189                 type            = procfile_lineword(ff, l, 0);
190
191                 if(do_rc == 1 && strcmp(type, "rc") == 0) {
192                         if(words < 4) {
193                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 4);
194                                 continue;
195                         }
196                         
197                         rc_hits = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
198                         rc_misses = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
199                         rc_nocache = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
200
201                         unsigned long long sum = rc_hits + rc_misses + rc_nocache;
202                         if(sum == 0ULL) do_rc = -1;
203                         else do_rc = 2;
204                 }
205                 else if(do_fh == 1 && strcmp(type, "fh") == 0) {
206                         if(words < 6) {
207                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
208                                 continue;
209                         }
210                         
211                         fh_stale = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
212                         fh_total_lookups = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
213                         fh_anonymous_lookups = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
214                         fh_dir_not_in_dcache = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
215                         fh_non_dir_not_in_dcache = strtoull(procfile_lineword(ff, l, 5), NULL, 10);
216
217                         unsigned long long sum = fh_stale + fh_total_lookups + fh_anonymous_lookups + fh_dir_not_in_dcache + fh_non_dir_not_in_dcache;
218                         if(sum == 0ULL) do_fh = -1;
219                         else do_fh = 2;
220                 }
221                 else if(do_io == 1 && strcmp(type, "io") == 0) {
222                         if(words < 3) {
223                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 3);
224                                 continue;
225                         }
226                         
227                         io_read = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
228                         io_write = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
229
230                         unsigned long long sum = io_read + io_write;
231                         if(sum == 0ULL) do_io = -1;
232                         else do_io = 2;
233                 }
234                 else if(do_th == 1 && strcmp(type, "th") == 0) {
235                         if(words < 13) {
236                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
237                                 continue;
238                         }
239                         
240                         th_threads = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
241                         th_fullcnt = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
242                         th_hist10 = (unsigned long long)(atof(procfile_lineword(ff, l, 3)) * 1000.0);
243                         th_hist20 = (unsigned long long)(atof(procfile_lineword(ff, l, 4)) * 1000.0);
244                         th_hist30 = (unsigned long long)(atof(procfile_lineword(ff, l, 5)) * 1000.0);
245                         th_hist40 = (unsigned long long)(atof(procfile_lineword(ff, l, 6)) * 1000.0);
246                         th_hist50 = (unsigned long long)(atof(procfile_lineword(ff, l, 7)) * 1000.0);
247                         th_hist60 = (unsigned long long)(atof(procfile_lineword(ff, l, 8)) * 1000.0);
248                         th_hist70 = (unsigned long long)(atof(procfile_lineword(ff, l, 9)) * 1000.0);
249                         th_hist80 = (unsigned long long)(atof(procfile_lineword(ff, l, 10)) * 1000.0);
250                         th_hist90 = (unsigned long long)(atof(procfile_lineword(ff, l, 11)) * 1000.0);
251                         th_hist100 = (unsigned long long)(atof(procfile_lineword(ff, l, 12)) * 1000.0);
252
253                         // threads histogram has been disabled on recent kernels
254                         // http://permalink.gmane.org/gmane.linux.nfs/24528
255                         unsigned long long sum = th_hist10 + th_hist20 + th_hist30 + th_hist40 + th_hist50 + th_hist60 + th_hist70 + th_hist80 + th_hist90 + th_hist100;
256                         if(sum == 0ULL) {
257                                 if(!th_warning) {
258                                         info("Disabling /proc/net/rpc/nfsd threads histogram. It seems useless on this machine. It will be enabled if it is found with data in it.");
259                                         th_warning = 1;
260                                 }
261                                 do_th = -1;
262                         }
263                         else do_th = 2;
264                 }
265                 else if(do_ra == 1 && strcmp(type, "ra") == 0) {
266                         if(words < 13) {
267                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
268                                 continue;
269                         }
270                         
271                         ra_size = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
272                         ra_hist10 = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
273                         ra_hist20 = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
274                         ra_hist30 = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
275                         ra_hist40 = strtoull(procfile_lineword(ff, l, 5), NULL, 10);
276                         ra_hist50 = strtoull(procfile_lineword(ff, l, 6), NULL, 10);
277                         ra_hist60 = strtoull(procfile_lineword(ff, l, 7), NULL, 10);
278                         ra_hist70 = strtoull(procfile_lineword(ff, l, 8), NULL, 10);
279                         ra_hist80 = strtoull(procfile_lineword(ff, l, 9), NULL, 10);
280                         ra_hist90 = strtoull(procfile_lineword(ff, l, 10), NULL, 10);
281                         ra_hist100 = strtoull(procfile_lineword(ff, l, 11), NULL, 10);
282                         ra_none = strtoull(procfile_lineword(ff, l, 12), NULL, 10);
283
284                         unsigned long long sum = ra_hist10 + ra_hist20 + ra_hist30 + ra_hist40 + ra_hist50 + ra_hist60 + ra_hist70 + ra_hist80 + ra_hist90 + ra_hist100 + ra_none;
285                         if(sum == 0ULL) {
286                                 if(!ra_warning) {
287                                         info("Disabling /proc/net/rpc/nfsd read ahead histogram. It seems useless on this machine. It will be enabled if it is found with data in it.");
288                                         ra_warning = 1;
289                                 }
290                                 do_ra = -1;
291                         }
292                         else do_ra = 2;
293                 }
294                 else if(do_net == 1 && strcmp(type, "net") == 0) {
295                         if(words < 5) {
296                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 5);
297                                 continue;
298                         }
299                         
300                         net_count = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
301                         net_udp_count = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
302                         net_tcp_count = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
303                         net_tcp_connections = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
304
305                         unsigned long long sum = net_count + net_udp_count + net_tcp_count + net_tcp_connections;
306                         if(sum == 0ULL) do_net = -1;
307                         else do_net = 2;
308                 }
309                 else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
310                         if(words < 6) {
311                                 error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
312                                 continue;
313                         }
314                         
315                         rpc_count = strtoull(procfile_lineword(ff, l, 1), NULL, 10);
316                         rpc_bad_format = strtoull(procfile_lineword(ff, l, 2), NULL, 10);
317                         rpc_bad_auth = strtoull(procfile_lineword(ff, l, 3), NULL, 10);
318                         rpc_bad_client = strtoull(procfile_lineword(ff, l, 4), NULL, 10);
319
320                         unsigned long long sum = rpc_count + rpc_bad_format + rpc_bad_auth + rpc_bad_client;
321                         if(sum == 0ULL) do_rpc = -1;
322                         else do_rpc = 2;
323                 }
324                 else if(do_proc2 == 1 && strcmp(type, "proc2") == 0) {
325                         // the first number is the count of numbers present
326                         // so we start for word 2
327
328                         unsigned long long sum = 0;
329                         unsigned int i, j;
330                         for(i = 0, j = 2; j < words && nfsd_proc_values[i].name[0] ; i++, j++) {
331                                 nfsd_proc_values[i].proc2 = strtoull(procfile_lineword(ff, l, j), NULL, 10);
332                                 nfsd_proc_values[i].present2 = 1;
333                                 sum += nfsd_proc_values[i].proc2;
334                         }
335
336                         if(sum == 0ULL) {
337                                 if(!proc2_warning) {
338                                         error("Disabling /proc/net/rpc/nfsd v2 procedure calls chart. It seems useless on this machine. It will be enabled if it is found with data in it.");
339                                         proc2_warning = 1;
340                                 }
341                                 do_proc2 = 0;
342                         }
343                         else do_proc2 = 2;
344                 }
345                 else if(do_proc3 == 1 && strcmp(type, "proc3") == 0) {
346                         // the first number is the count of numbers present
347                         // so we start for word 2
348
349                         unsigned long long sum = 0;
350                         unsigned int i, j;
351                         for(i = 0, j = 2; j < words && nfsd_proc_values[i].name[0] ; i++, j++) {
352                                 nfsd_proc_values[i].proc3 = strtoull(procfile_lineword(ff, l, j), NULL, 10);
353                                 nfsd_proc_values[i].present3 = 1;
354                                 sum += nfsd_proc_values[i].proc3;
355                         }
356
357                         if(sum == 0ULL) {
358                                 if(!proc3_warning) {
359                                         info("Disabling /proc/net/rpc/nfsd v3 procedure calls chart. It seems useless on this machine. It will be enabled if it is found with data in it.");
360                                         proc3_warning = 1;
361                                 }
362                                 do_proc3 = 0;
363                         }
364                         else do_proc3 = 2;
365                 }
366                 else if(do_proc4 == 1 && strcmp(type, "proc4") == 0) {
367                         // the first number is the count of numbers present
368                         // so we start for word 2
369
370                         unsigned long long sum = 0;
371                         unsigned int i, j;
372                         for(i = 0, j = 2; j < words && nfsd_proc_values[i].name[0] ; i++, j++) {
373                                 nfsd_proc_values[i].proc4 = strtoull(procfile_lineword(ff, l, j), NULL, 10);
374                                 nfsd_proc_values[i].present4 = 1;
375                                 sum += nfsd_proc_values[i].proc4;
376                         }
377
378                         if(sum == 0ULL) {
379                                 if(!proc4_warning) {
380                                         info("Disabling /proc/net/rpc/nfsd v4 procedure calls chart. It seems useless on this machine. It will be enabled if it is found with data in it.");
381                                         proc4_warning = 1;
382                                 }
383                                 do_proc4 = 0;
384                         }
385                         else do_proc4 = 2;
386                 }
387                 else if(do_proc4ops == 1 && strcmp(type, "proc4ops") == 0) {
388                         // the first number is the count of numbers present
389                         // so we start for word 2
390
391                         unsigned long long sum = 0;
392                         unsigned int i, j;
393                         for(i = 0, j = 2; j < words && nfsd4_ops_values[i].name[0] ; i++, j++) {
394                                 nfsd4_ops_values[i].value = strtoull(procfile_lineword(ff, l, j), NULL, 10);
395                                 nfsd4_ops_values[i].present = 1;
396                                 sum += nfsd4_ops_values[i].value;
397                         }
398
399                         if(sum == 0ULL) {
400                                 if(!proc4ops_warning) {
401                                         info("Disabling /proc/net/rpc/nfsd v4 operations chart. It seems useless on this machine. It will be enabled if it is found with data in it.");
402                                         proc4ops_warning = 1;
403                                 }
404                                 do_proc4ops = 0;
405                         }
406                         else do_proc4ops = 2;
407                 }
408         }
409
410         RRDSET *st;
411
412         // --------------------------------------------------------------------
413
414         if(do_rc == 2) {
415                 st = rrdset_find_bytype("nfsd", "readcache");
416                 if(!st) {
417                         st = rrdset_create("nfsd", "readcache", NULL, "nfsd", "Read Cache", "reads/s", 5000, update_every, RRDSET_TYPE_STACKED);
418
419                         rrddim_add(st, "hits", NULL, 1, update_every, RRDDIM_INCREMENTAL);
420                         rrddim_add(st, "misses", NULL, 1, update_every, RRDDIM_INCREMENTAL);
421                         rrddim_add(st, "nocache", NULL, 1, update_every, RRDDIM_INCREMENTAL);
422                 }
423                 else rrdset_next(st);
424
425                 rrddim_set(st, "hits", rc_hits);
426                 rrddim_set(st, "misses", rc_misses);
427                 rrddim_set(st, "nocache", rc_nocache);
428                 rrdset_done(st);
429         }
430
431         // --------------------------------------------------------------------
432
433         if(do_fh == 2) {
434                 st = rrdset_find_bytype("nfsd", "filehandles");
435                 if(!st) {
436                         st = rrdset_create("nfsd", "filehandles", NULL, "nfsd", "File Handles", "handles/s", 5001, update_every, RRDSET_TYPE_LINE);
437                         st->isdetail = 1;
438
439                         rrddim_add(st, "stale", NULL, 1, update_every, RRDDIM_ABSOLUTE);
440                         rrddim_add(st, "total_lookups", NULL, 1, update_every, RRDDIM_INCREMENTAL);
441                         rrddim_add(st, "anonymous_lookups", NULL, 1, update_every, RRDDIM_INCREMENTAL);
442                         rrddim_add(st, "dir_not_in_dcache", NULL, -1, update_every, RRDDIM_INCREMENTAL);
443                         rrddim_add(st, "non_dir_not_in_dcache", NULL, -1, update_every, RRDDIM_INCREMENTAL);
444                 }
445                 else rrdset_next(st);
446
447                 rrddim_set(st, "stale", fh_stale);
448                 rrddim_set(st, "total_lookups", fh_total_lookups);
449                 rrddim_set(st, "anonymous_lookups", fh_anonymous_lookups);
450                 rrddim_set(st, "dir_not_in_dcache", fh_dir_not_in_dcache);
451                 rrddim_set(st, "non_dir_not_in_dcache", fh_non_dir_not_in_dcache);
452                 rrdset_done(st);
453         }
454
455         // --------------------------------------------------------------------
456
457         if(do_io == 2) {
458                 st = rrdset_find_bytype("nfsd", "io");
459                 if(!st) {
460                         st = rrdset_create("nfsd", "io", NULL, "nfsd", "I/O", "kilobytes/s", 5002, update_every, RRDSET_TYPE_AREA);
461
462                         rrddim_add(st, "read", NULL, 1, 1000 * update_every, RRDDIM_INCREMENTAL);
463                         rrddim_add(st, "write", NULL, -1, 1000 * update_every, RRDDIM_INCREMENTAL);
464                 }
465                 else rrdset_next(st);
466
467                 rrddim_set(st, "read", io_read);
468                 rrddim_set(st, "write", io_write);
469                 rrdset_done(st);
470         }
471
472         // --------------------------------------------------------------------
473
474         if(do_th == 2) {
475                 st = rrdset_find_bytype("nfsd", "threads");
476                 if(!st) {
477                         st = rrdset_create("nfsd", "threads", NULL, "nfsd", "Threads", "threads", 5003, update_every, RRDSET_TYPE_LINE);
478
479                         rrddim_add(st, "threads", NULL, 1, 1, RRDDIM_ABSOLUTE);
480                 }
481                 else rrdset_next(st);
482
483                 rrddim_set(st, "threads", th_threads);
484                 rrdset_done(st);
485
486                 st = rrdset_find_bytype("nfsd", "threads_fullcnt");
487                 if(!st) {
488                         st = rrdset_create("nfsd", "threads_fullcnt", NULL, "nfsd", "Threads Full Count", "ops/s", 5004, update_every, RRDSET_TYPE_LINE);
489
490                         rrddim_add(st, "full_count", NULL, 1, update_every, RRDDIM_INCREMENTAL);
491                 }
492                 else rrdset_next(st);
493
494                 rrddim_set(st, "full_count", th_fullcnt);
495                 rrdset_done(st);
496
497                 st = rrdset_find_bytype("nfsd", "threads_histogram");
498                 if(!st) {
499                         st = rrdset_create("nfsd", "threads_histogram", NULL, "nfsd", "Threads Usage Histogram", "percentage", 5005, update_every, RRDSET_TYPE_LINE);
500
501                         rrddim_add(st, "0%-10%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
502                         rrddim_add(st, "10%-20%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
503                         rrddim_add(st, "20%-30%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
504                         rrddim_add(st, "30%-40%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
505                         rrddim_add(st, "40%-50%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
506                         rrddim_add(st, "50%-60%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
507                         rrddim_add(st, "60%-70%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
508                         rrddim_add(st, "70%-80%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
509                         rrddim_add(st, "80%-90%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
510                         rrddim_add(st, "90%-100%", NULL, 1, 1000, RRDDIM_ABSOLUTE);
511                 }
512                 else rrdset_next(st);
513
514                 rrddim_set(st, "0%-10%", th_hist10);
515                 rrddim_set(st, "10%-20%", th_hist20);
516                 rrddim_set(st, "20%-30%", th_hist30);
517                 rrddim_set(st, "30%-40%", th_hist40);
518                 rrddim_set(st, "40%-50%", th_hist50);
519                 rrddim_set(st, "50%-60%", th_hist60);
520                 rrddim_set(st, "60%-70%", th_hist70);
521                 rrddim_set(st, "70%-80%", th_hist80);
522                 rrddim_set(st, "80%-90%", th_hist90);
523                 rrddim_set(st, "90%-100%", th_hist100);
524                 rrdset_done(st);
525         }
526
527         // --------------------------------------------------------------------
528
529         if(do_ra == 2) {
530                 st = rrdset_find_bytype("nfsd", "readahead");
531                 if(!st) {
532                         st = rrdset_create("nfsd", "readahead", NULL, "nfsd", "Read Ahead Depth", "percentage", 5005, update_every, RRDSET_TYPE_STACKED);
533
534                         rrddim_add(st, "10%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
535                         rrddim_add(st, "20%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
536                         rrddim_add(st, "30%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
537                         rrddim_add(st, "40%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
538                         rrddim_add(st, "50%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
539                         rrddim_add(st, "60%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
540                         rrddim_add(st, "70%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
541                         rrddim_add(st, "80%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
542                         rrddim_add(st, "90%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
543                         rrddim_add(st, "100%", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
544                         rrddim_add(st, "misses", NULL, 1, update_every, RRDDIM_PCENT_OVER_DIFF_TOTAL);
545                 }
546                 else rrdset_next(st);
547
548                 // ignore ra_size
549                 if(ra_size) {};
550
551                 rrddim_set(st, "10%", ra_hist10);
552                 rrddim_set(st, "20%", ra_hist20);
553                 rrddim_set(st, "30%", ra_hist30);
554                 rrddim_set(st, "40%", ra_hist40);
555                 rrddim_set(st, "50%", ra_hist50);
556                 rrddim_set(st, "60%", ra_hist60);
557                 rrddim_set(st, "70%", ra_hist70);
558                 rrddim_set(st, "80%", ra_hist80);
559                 rrddim_set(st, "90%", ra_hist90);
560                 rrddim_set(st, "100%", ra_hist100);
561                 rrddim_set(st, "misses", ra_none);
562                 rrdset_done(st);
563         }
564
565         // --------------------------------------------------------------------
566
567         if(do_net == 2) {
568                 st = rrdset_find_bytype("nfsd", "net");
569                 if(!st) {
570                         st = rrdset_create("nfsd", "net", NULL, "nfsd", "Network Reads", "reads/s", 5007, update_every, RRDSET_TYPE_STACKED);
571                         st->isdetail = 1;
572
573                         rrddim_add(st, "udp", NULL, 1, update_every, RRDDIM_INCREMENTAL);
574                         rrddim_add(st, "tcp", NULL, 1, update_every, RRDDIM_INCREMENTAL);
575                 }
576                 else rrdset_next(st);
577
578                 // ignore net_count, net_tcp_connections
579                 if(net_count) {};
580                 if(net_tcp_connections) {};
581
582                 rrddim_set(st, "udp", net_udp_count);
583                 rrddim_set(st, "tcp", net_tcp_count);
584                 rrdset_done(st);
585         }
586
587         // --------------------------------------------------------------------
588
589         if(do_rpc == 2) {
590                 st = rrdset_find_bytype("nfsd", "rpc");
591                 if(!st) {
592                         st = rrdset_create("nfsd", "rpc", NULL, "nfsd", "Remote Procedure Calls", "calls/s", 5008, update_every, RRDSET_TYPE_LINE);
593                         st->isdetail = 1;
594
595                         rrddim_add(st, "all", NULL, 1, update_every, RRDDIM_INCREMENTAL);
596                         rrddim_add(st, "bad_format", NULL, -1, update_every, RRDDIM_INCREMENTAL);
597                         rrddim_add(st, "bad_auth", NULL, -1, update_every, RRDDIM_INCREMENTAL);
598                 }
599                 else rrdset_next(st);
600
601                 // ignore rpc_bad_client
602                 if(rpc_bad_client) {};
603
604                 rrddim_set(st, "all", rpc_count);
605                 rrddim_set(st, "bad_format", rpc_bad_format);
606                 rrddim_set(st, "bad_auth", rpc_bad_auth);
607                 rrdset_done(st);
608         }
609
610         // --------------------------------------------------------------------
611
612         if(do_proc2 == 2) {
613                 unsigned int i;
614                 st = rrdset_find_bytype("nfsd", "proc2");
615                 if(!st) {
616                         st = rrdset_create("nfsd", "proc2", NULL, "nfsd", "NFS v2 Calls", "calls/s", 5009, update_every, RRDSET_TYPE_STACKED);
617
618                         for(i = 0; nfsd_proc_values[i].present2 ; i++)
619                                 rrddim_add(st, nfsd_proc_values[i].name, NULL, 1, update_every, RRDDIM_INCREMENTAL);
620                 }
621                 else rrdset_next(st);
622
623                 for(i = 0; nfsd_proc_values[i].present2 ; i++)
624                         rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc2);
625                 
626                 rrdset_done(st);
627         }
628
629         // --------------------------------------------------------------------
630
631         if(do_proc3 == 2) {
632                 unsigned int i;
633                 st = rrdset_find_bytype("nfsd", "proc3");
634                 if(!st) {
635                         st = rrdset_create("nfsd", "proc3", NULL, "nfsd", "NFS v3 Calls", "calls/s", 5010, update_every, RRDSET_TYPE_STACKED);
636
637                         for(i = 0; nfsd_proc_values[i].present3 ; i++)
638                                 rrddim_add(st, nfsd_proc_values[i].name, NULL, 1, update_every, RRDDIM_INCREMENTAL);
639                 }
640                 else rrdset_next(st);
641
642                 for(i = 0; nfsd_proc_values[i].present3 ; i++)
643                         rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc3);
644                 
645                 rrdset_done(st);
646         }
647
648         // --------------------------------------------------------------------
649
650         if(do_proc4 == 2) {
651                 unsigned int i;
652                 st = rrdset_find_bytype("nfsd", "proc4");
653                 if(!st) {
654                         st = rrdset_create("nfsd", "proc4", NULL, "nfsd", "NFS v4 Calls", "calls/s", 5011, update_every, RRDSET_TYPE_STACKED);
655
656                         for(i = 0; nfsd_proc_values[i].present4 ; i++)
657                                 rrddim_add(st, nfsd_proc_values[i].name, NULL, 1, update_every, RRDDIM_INCREMENTAL);
658                 }
659                 else rrdset_next(st);
660
661                 for(i = 0; nfsd_proc_values[i].present4 ; i++)
662                         rrddim_set(st, nfsd_proc_values[i].name, nfsd_proc_values[i].proc4);
663                 
664                 rrdset_done(st);
665         }
666
667         // --------------------------------------------------------------------
668
669         if(do_proc4ops == 2) {
670                 unsigned int i;
671                 st = rrdset_find_bytype("nfsd", "proc4ops");
672                 if(!st) {
673                         st = rrdset_create("nfsd", "proc4ops", NULL, "nfsd", "NFS v4 Operations", "operations/s", 5012, update_every, RRDSET_TYPE_STACKED);
674
675                         for(i = 0; nfsd4_ops_values[i].present ; i++)
676                                 rrddim_add(st, nfsd4_ops_values[i].name, NULL, 1, update_every, RRDDIM_INCREMENTAL);
677                 }
678                 else rrdset_next(st);
679
680                 for(i = 0; nfsd4_ops_values[i].present ; i++)
681                         rrddim_set(st, nfsd4_ops_values[i].name, nfsd4_ops_values[i].value);
682                 
683                 rrdset_done(st);
684         }
685
686         return 0;
687 }