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