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