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