2 * Copyright (c) 1983, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * Copyright (c) 2004, 2008, 2009 Silicon Graphics International Corp.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions, and the following disclaimer,
41 * without modification.
42 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
43 * substantially similar to the "NO WARRANTY" disclaimer below
44 * ("Disclaimer") and any redistribution must be conditioned upon
45 * including a substantially similar Disclaimer requirement for further
46 * binary redistribution.
49 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
50 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
51 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
52 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
53 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
57 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
58 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59 * POSSIBILITY OF SUCH DAMAGES.
63 #include <sys/param.h>
64 #include <sys/module.h>
65 #include <sys/mount.h>
67 #include <sys/sysctl.h>
68 #include <nfs/nfssvc.h>
70 #include <fs/nfs/nfsproto.h>
71 #include <fs/nfs/nfsport.h>
90 static int widemode = 0;
92 static int printtitle = 1;
93 static struct nfsstatsv1 ext_nfsstats;
94 static int extra_output = 0;
96 static void intpr(int, int);
97 static void printhdr(int, int, int);
98 static void usage(void) __dead2;
99 static char *sperc1(int, int);
100 static char *sperc2(int, int);
101 static void exp_intpr(int, int, int);
102 static void exp_sidewaysintpr(u_int, int, int, int);
103 static void compute_new_stats(struct nfsstatsv1 *cur_stats,
104 struct nfsstatsv1 *prev_stats, int curop, long double etime,
105 long double *mbsec, long double *kb_per_transfer,
106 long double *transfers_per_second, long double *ms_per_transfer,
107 uint64_t *queue_len, long double *busy_pct);
109 #define DELTA(field) (nfsstats.field - lastst.field)
111 #define STAT_TYPE_READ 0
112 #define STAT_TYPE_WRITE 1
113 #define STAT_TYPE_COMMIT 2
114 #define NUM_STAT_TYPES 3
120 static struct stattypes statstruct[] = {
121 {STAT_TYPE_READ, NFSV4OP_READ},
122 {STAT_TYPE_WRITE, NFSV4OP_WRITE},
123 {STAT_TYPE_COMMIT, NFSV4OP_COMMIT}
126 #define STAT_TYPE_TO_NFS(stat_type) statstruct[stat_type].nfs_type
128 #define NFSSTAT_XO_VERSION "1"
131 main(int argc, char **argv)
140 struct statfs *mntbuf;
141 struct nfscl_dumpmntopts dumpmntopts;
145 argc = xo_parse_args(argc, argv);
149 xo_set_version(NFSSTAT_XO_VERSION);
151 while ((ch = getopt(argc, argv, "cdEesWM:mN:w:zq")) != -1)
154 printf("*** -M option deprecated, ignored\n\n");
157 /* Display mount options for NFS mount points. */
158 mntlen = getmntinfo(&mntbuf, MNT_NOWAIT);
159 for (i = 0; i < mntlen; i++) {
160 if (strcmp(mntbuf->f_fstypename, "nfs") == 0) {
161 dumpmntopts.ndmnt_fname =
163 dumpmntopts.ndmnt_buf = buf;
164 dumpmntopts.ndmnt_blen = sizeof(buf);
165 if (nfssvc(NFSSVC_DUMPMNTOPTS,
167 printf("%s on %s\n%s\n",
168 mntbuf->f_mntfromname,
169 mntbuf->f_mntonname, buf);
170 else if (errno == EPERM)
171 errx(1, "Only privileged users"
172 " can use the -m option");
178 printf("*** -N option deprecated, ignored\n\n");
184 interval = atoi(optarg);
205 if (extra_output != 0)
206 xo_err(1, "-e and -E are mutually exclusive");
210 if (extra_output != 0)
211 xo_err(1, "-e and -E are mutually exclusive");
224 #define BACKWARD_COMPATIBILITY
225 #ifdef BACKWARD_COMPATIBILITY
227 interval = atoi(*argv);
229 if (modfind("nfscommon") < 0)
230 xo_err(1, "NFS client/server not loaded");
233 exp_sidewaysintpr(interval, clientOnly, serverOnly,
236 xo_open_container("nfsstat");
237 if (extra_output != 0)
238 exp_intpr(clientOnly, serverOnly, extra_output - 1);
240 intpr(clientOnly, serverOnly);
241 xo_close_container("nfsstat");
249 * Print a description of the nfs stats.
252 intpr(int clientOnly, int serverOnly)
256 nfssvc_flag = NFSSVC_GETSTATS | NFSSVC_NEWSTRUCT;
259 nfssvc_flag |= NFSSVC_ZEROCLTSTATS;
261 nfssvc_flag |= NFSSVC_ZEROSRVSTATS;
263 ext_nfsstats.vers = NFSSTATS_V1;
264 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0)
265 xo_err(1, "Can't get stats");
267 xo_open_container("clientstats");
270 xo_emit("{T:Client Info:\n");
272 xo_open_container("operations");
273 xo_emit("{T:Rpc Counts:}\n");
275 xo_emit("{T:Getattr/%13.13s}{T:Setattr/%13.13s}"
276 "{T:Lookup/%13.13s}{T:Readlink/%13.13s}"
277 "{T:Read/%13.13s}{T:Write/%13.13s}"
278 "{T:Create/%13.13s}{T:Remove/%13.13s}\n");
279 xo_emit("{:getattr/%13ju}{:setattr/%13ju}"
280 "{:lookup/%13ju}{:readlink/%13ju}"
281 "{:read/%13ju}{:write/%13ju}"
282 "{:create/%13ju}{:remove/%13ju}\n",
283 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETATTR],
284 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETATTR],
285 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOOKUP],
286 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READLINK],
287 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READ],
288 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_WRITE],
289 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CREATE],
290 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_REMOVE]);
292 xo_emit("{T:Rename/%13.13s}{T:Link/%13.13s}"
293 "{T:Symlink/%13.13s}{T:Mkdir/%13.13s}"
294 "{T:Rmdir/%13.13s}{T:Readdir/%13.13s}"
295 "{T:RdirPlus/%13.13s}{T:Access/%13.13s}\n");
296 xo_emit("{:rename/%13ju}{:link/%13ju}"
297 "{:symlink/%13ju}{:mkdir/%13ju}"
298 "{:rmdir/%13ju}{:readdir/%13ju}"
299 "{:rdirplus/%13ju}{:access/%13ju}\n",
300 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RENAME],
301 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LINK],
302 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SYMLINK],
303 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_MKDIR],
304 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RMDIR],
305 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READDIR],
306 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS],
307 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_ACCESS]);
309 xo_emit("{T:Mknod/%13.13s}{T:Fsstat/%13.13s}"
310 "{T:Fsinfo/%13.13s}{T:PathConf/%13.13s}"
311 "{T:Commit/%13.13s}\n");
312 xo_emit("{:mknod/%13ju}{:fsstat/%13ju}"
313 "{:fsinfo/%13ju}{:pathconf/%13ju}"
315 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_MKNOD],
316 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FSSTAT],
317 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FSINFO],
318 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_PATHCONF],
319 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_COMMIT]);
321 xo_close_container("operations");
323 xo_open_container("rpcs");
324 xo_emit("{T:Rpc Info:}\n");
326 xo_emit("{T:TimedOut/%13.13s}{T:Invalid/%13.13s}"
327 "{T:X Replies/%13.13s}{T:Retries/%13.13s}"
328 "{T:Requests/%13.13s}\n");
329 xo_emit("{:timedout/%13ju}{:invalid/%13ju}"
330 "{:xreplies/%13ju}{:retries/%13ju}"
331 "{:requests/%13ju}\n",
332 (uintmax_t)ext_nfsstats.rpctimeouts,
333 (uintmax_t)ext_nfsstats.rpcinvalid,
334 (uintmax_t)ext_nfsstats.rpcunexpected,
335 (uintmax_t)ext_nfsstats.rpcretries,
336 (uintmax_t)ext_nfsstats.rpcrequests);
337 xo_close_container("rpcs");
339 xo_open_container("cache");
340 xo_emit("{T:Cache Info:}\n");
342 xo_emit("{T:Attr Hits/%13.13s}{T:Attr Misses/%13.13s}"
343 "{T:Lkup Hits/%13.13s}{T:Lkup Misses/%13.13s}"
344 "{T:BioR Hits/%13.13s}{T:BioR Misses/%13.13s}"
345 "{T:BioW Hits/%13.13s}{T:BioW Misses/%13.13s}\n");
346 xo_emit("{:attrhits/%13ju}{:attrmisses/%13ju}"
347 "{:lkuphits/%13ju}{:lkupmisses/%13ju}"
348 "{:biorhits/%13ju}{:biormisses/%13ju}"
349 "{:biowhits/%13ju}{:biowmisses/%13ju}\n",
350 (uintmax_t)ext_nfsstats.attrcache_hits,
351 (uintmax_t)ext_nfsstats.attrcache_misses,
352 (uintmax_t)ext_nfsstats.lookupcache_hits,
353 (uintmax_t)ext_nfsstats.lookupcache_misses,
354 (uintmax_t)(ext_nfsstats.biocache_reads -
355 ext_nfsstats.read_bios),
356 (uintmax_t)ext_nfsstats.read_bios,
357 (uintmax_t)(ext_nfsstats.biocache_writes -
358 ext_nfsstats.write_bios),
359 (uintmax_t)ext_nfsstats.write_bios);
361 xo_emit("{T:BioRL Hits/%13.13s}{T:BioRL Misses/%13.13s}"
362 "{T:BioD Hits/%13.13s}{T:BioD Misses/%13.13s}"
363 "{T:DirE Hits/%13.13s}{T:DirE Misses/%13.13s}"
364 "{T:Accs Hits/%13.13s}{T:Accs Misses/%13.13s}\n");
365 xo_emit("{:biosrlhits/%13ju}{:biorlmisses/%13ju}"
366 "{:biodhits/%13ju}{:biodmisses/%13ju}"
367 "{:direhits/%13ju}{:diremisses/%13ju}"
368 "{:accshits/%13ju}{:accsmisses/%13ju}\n",
369 (uintmax_t)(ext_nfsstats.biocache_readlinks -
370 ext_nfsstats.readlink_bios),
371 (uintmax_t)ext_nfsstats.readlink_bios,
372 (uintmax_t)(ext_nfsstats.biocache_readdirs -
373 ext_nfsstats.readdir_bios),
374 (uintmax_t)ext_nfsstats.readdir_bios,
375 (uintmax_t)ext_nfsstats.direofcache_hits,
376 (uintmax_t)ext_nfsstats.direofcache_misses,
377 (uintmax_t)ext_nfsstats.accesscache_hits,
378 (uintmax_t)ext_nfsstats.accesscache_misses);
380 xo_close_container("cache");
382 xo_close_container("clientstats");
385 xo_open_container("serverstats");
387 xo_emit("{T:Server Info:}\n");
388 xo_open_container("operations");
390 xo_emit("{T:Getattr/%13.13s}{T:Setattr/%13.13s}"
391 "{T:Lookup/%13.13s}{T:Readlink/%13.13s}"
392 "{T:Read/%13.13s}{T:Write/%13.13s}"
393 "{T:Create/%13.13s}{T:Remove/%13.13s}\n");
394 xo_emit("{:getattr/%13ju}{:setattr/%13ju}"
395 "{:lookup/%13ju}{:readlink/%13ju}"
396 "{:read/%13ju}{:write/%13ju}"
397 "{:create/%13ju}{:remove/%13ju}\n",
398 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR],
399 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR],
400 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP],
401 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READLINK],
402 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READ],
403 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITE],
404 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_CREATE],
405 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]);
407 xo_emit("{T:Rename/%13.13s}{T:Link/%13.13s}"
408 "{T:Symlink/%13.13s}{T:Mkdir/%13.13s}"
409 "{T:Rmdir/%13.13s}{T:Readdir/%13.13s}"
410 "{T:RdirPlus/%13.13s}{T:Access/%13.13s}\n");
411 xo_emit("{:rename/%13ju}{:link/%13ju}"
412 "{:symlink/%13ju}{:mkdir/%13ju}"
413 "{:rmdir/%13ju}{:readdir/%13ju}"
414 "{:rdirplus/%13ju}{:access/%13ju}\n",
415 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RENAME],
416 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LINK],
417 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK],
418 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR],
419 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR],
420 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READDIR],
421 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS],
422 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]);
424 xo_emit("{T:Mknod/%13.13s}{T:Fsstat/%13.13s}"
425 "{T:Fsinfo/%13.13s}{T:PathConf/%13.13s}"
426 "{T:Commit/%13.13s}\n");
427 xo_emit("{:mknod/%13ju}{:fsstat/%13ju}"
428 "{:fsinfo/%13ju}{:pathconf/%13ju}"
430 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD],
431 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT],
432 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO],
433 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF],
434 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT]);
436 xo_close_container("operations");
438 xo_open_container("server");
440 xo_emit("{T:Server Write Gathering:/%13.13s}\n");
442 xo_emit("{T:WriteOps/%13.13s}{T:WriteRPC/%13.13s}"
443 "{T:Opsaved/%13.13s}\n");
444 xo_emit("{:writeops/%13ju}{:writerpc/%13ju}"
445 "{:opsaved/%13ju}\n",
447 * The new client doesn't do write gathering. It was
448 * only useful for NFSv2.
450 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITE],
451 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 0);
453 xo_close_container("server");
455 xo_open_container("cache");
456 xo_emit("{T:Server Cache Stats:/%13.13s}\n");
457 xo_emit("{T:Inprog/%13.13s}"
458 "{T:Non-Idem/%13.13s}{T:Misses/%13.13s}\n");
459 xo_emit("{:inprog/%13ju}{:nonidem/%13ju}{:misses/%13ju}\n",
460 (uintmax_t)ext_nfsstats.srvcache_inproghits,
461 (uintmax_t)ext_nfsstats.srvcache_nonidemdonehits,
462 (uintmax_t)ext_nfsstats.srvcache_misses);
463 xo_close_container("cache");
465 xo_close_container("serverstats");
470 printhdr(int clientOnly, int serverOnly, int newStats)
474 printf(" [%s Read %s] [%s Write %s] "
475 "%s[=========== Total ============]\n"
476 " KB/t tps MB/s%s KB/t tps MB/s%s "
477 "%sKB/t tps MB/s ms ql %%b",
478 widemode ? "========" : "=====",
479 widemode ? "========" : "=====",
480 widemode ? "========" : "=====",
481 widemode ? "=======" : "====",
482 widemode ? "[Commit ] " : "",
483 widemode ? " ms" : "",
484 widemode ? " ms" : "",
485 widemode ? "tps ms " : "");
487 printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
488 ((serverOnly && clientOnly) ? " " : " "),
489 "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename",
491 if (widemode && clientOnly) {
492 printf(" Attr Lkup BioR BioW Accs BioD");
502 (void)fprintf(stderr,
503 "usage: nfsstat [-cdemszW] [-w wait]\n");
507 static char SPBuf[64][8];
511 sperc1(int hits, int misses)
513 char *p = SPBuf[SPIndex];
517 (int)(char)((quad_t)hits * 100 / (hits + misses)));
521 SPIndex = (SPIndex + 1) & 63;
526 sperc2(int ttl, int misses)
528 char *p = SPBuf[SPIndex];
532 (int)(char)((quad_t)(ttl - misses) * 100 / ttl));
536 SPIndex = (SPIndex + 1) & 63;
540 #define DELTA_T(field) \
541 devstat_compute_etime(&cur_stats->field, \
542 (prev_stats ? &prev_stats->field : NULL))
545 * XXX KDM mostly copied from ctlstat. We should commonize the code (and
546 * the devstat code) somehow.
549 compute_new_stats(struct nfsstatsv1 *cur_stats,
550 struct nfsstatsv1 *prev_stats, int curop,
551 long double etime, long double *mbsec,
552 long double *kb_per_transfer,
553 long double *transfers_per_second,
554 long double *ms_per_transfer, uint64_t *queue_len,
555 long double *busy_pct)
557 uint64_t total_bytes = 0, total_operations = 0;
558 struct bintime total_time_bt;
559 struct timespec total_time_ts;
561 bzero(&total_time_bt, sizeof(total_time_bt));
562 bzero(&total_time_ts, sizeof(total_time_ts));
564 total_bytes = cur_stats->srvbytes[curop];
565 total_operations = cur_stats->srvops[curop];
566 if (prev_stats != NULL) {
567 total_bytes -= prev_stats->srvbytes[curop];
568 total_operations -= prev_stats->srvops[curop];
571 *mbsec = total_bytes;
572 *mbsec /= 1024 * 1024;
574 *busy_pct = DELTA_T(busytime);
586 *kb_per_transfer = total_bytes;
587 *kb_per_transfer /= 1024;
588 if (total_operations > 0)
589 *kb_per_transfer /= total_operations;
591 *kb_per_transfer = 0;
593 *transfers_per_second = total_operations;
594 *transfers_per_second /= etime;
596 *transfers_per_second = 0.0;
599 if (total_operations > 0) {
600 *ms_per_transfer = DELTA_T(srvduration[curop]);
601 *ms_per_transfer /= total_operations;
602 *ms_per_transfer *= 1000;
604 *ms_per_transfer = 0.0;
606 *queue_len = cur_stats->srvstartcnt - cur_stats->srvdonecnt;
610 * Print a description of the nfs stats for the client/server,
614 exp_intpr(int clientOnly, int serverOnly, int nfs41)
618 xo_open_container("nfsv4");
620 nfssvc_flag = NFSSVC_GETSTATS | NFSSVC_NEWSTRUCT;
623 nfssvc_flag |= NFSSVC_ZEROCLTSTATS;
625 nfssvc_flag |= NFSSVC_ZEROSRVSTATS;
627 ext_nfsstats.vers = NFSSTATS_V1;
628 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0)
629 xo_err(1, "Can't get stats");
630 if (clientOnly != 0) {
631 xo_open_container("clientstats");
633 xo_open_container("operations");
635 xo_emit("{T:Client Info:}\n");
636 xo_emit("{T:RPC Counts:}\n");
638 xo_emit("{T:Getattr/%13.13s}{T:Setattr/%13.13s}"
639 "{T:Lookup/%13.13s}{T:Readlink/%13.13s}"
640 "{T:Read/%13.13s}{T:Write/%13.13s}\n");
641 xo_emit("{:getattr/%13ju}{:setattr/%13ju}{:lookup/%13ju}"
642 "{:readlink/%13ju}{:read/%13ju}{:write/%13ju}\n",
643 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETATTR],
644 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETATTR],
645 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOOKUP],
646 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READLINK],
647 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READ],
648 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_WRITE]);
649 xo_emit("{T:Create/%13.13s}{T:Remove/%13.13s}"
650 "{T:Rename/%13.13s}{T:Link/%13.13s}"
651 "{T:Symlink/%13.13s}{T:Mkdir/%13.13s}\n");
652 xo_emit("{:create/%13ju}{:remove/%13ju}{:rename/%13ju}"
653 "{:link/%13ju}{:symlink/%13ju}{:mkdir/%13ju}\n",
654 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CREATE],
655 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_REMOVE],
656 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RENAME],
657 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LINK],
658 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SYMLINK],
659 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_MKDIR]);
660 xo_emit("{T:Rmdir/%13.13s}{T:Readdir/%13.13s}"
661 "{T:RdirPlus/%13.13s}{T:Access/%13.13s}"
662 "{T:Mknod/%13.13s}{T:Fsstat/%13.13s}\n");
663 xo_emit("{:rmdir/%13ju}{:readdir/%13ju}{:rdirplus/%13ju}"
664 "{:access/%13ju}{:mknod/%13ju}{:fsstat/%13ju}\n",
665 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RMDIR],
666 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READDIR],
667 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS],
668 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_ACCESS],
669 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_MKNOD],
670 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FSSTAT]);
671 xo_emit("{T:FSinfo/%13.13s}{T:pathConf/%13.13s}"
672 "{T:Commit/%13.13s}{T:SetClId/%13.13s}"
673 "{T:SetClIdCf/%13.13s}{T:Lock/%13.13s}\n");
674 xo_emit("{:fsinfo/%13ju}{:pathconf/%13ju}{:commit/%13ju}"
675 "{:setclientid/%13ju}{:setclientidcf/%13ju}{:lock/%13ju}\n",
676 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FSINFO],
677 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_PATHCONF],
678 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_COMMIT],
679 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID],
680 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM],
681 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOCK]);
682 xo_emit("{T:LockT/%13.13s}{T:LockU/%13.13s}"
683 "{T:Open/%13.13s}{T:OpenCfr/%13.13s}\n");
684 xo_emit("{:lockt/%13ju}{:locku/%13ju}"
685 "{:open/%13ju}{:opencfr/%13ju}\n",
686 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOCKT],
687 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOCKU],
688 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_OPEN],
689 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]);
692 xo_open_container("nfsv41");
694 xo_emit("{T:OpenDownGr/%13.13s}{T:Close/%13.13s}\n");
695 xo_emit("{:opendowngr/%13ju}{:close/%13ju}\n",
696 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_OPENDOWNGRADE],
697 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CLOSE]);
699 xo_emit("{T:RelLckOwn/%13.13s}{T:FreeStateID/%13.13s}"
700 "{T:PutRootFH/%13.13s}{T:DelegRet/%13.13s}"
701 "{T:GetAcl/%13.13s}{T:SetAcl/%13.13s}\n");
702 xo_emit("{:rellckown/%13ju}{:freestateid/%13ju}"
703 "{:putrootfh/%13ju}{:delegret/%13ju}"
704 "{:getacl/%13ju}{:setacl/%13ju}\n",
705 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RELEASELCKOWN],
706 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_FREESTATEID],
707 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_PUTROOTFH],
708 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_DELEGRETURN],
709 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETACL],
710 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETACL]);
712 xo_emit("{T:ExchangeId/%13.13s}{T:CreateSess/%13.13s}"
713 "{T:DestroySess/%13.13s}{T:DestroyClId/%13.13s}"
714 "{T:LayoutGet/%13.13s}{T:GetDevInfo/%13.13s}\n");
715 xo_emit("{:exchangeid/%13ju}{:createsess/%13ju}"
716 "{:destroysess/%13ju}{:destroyclid/%13ju}"
717 "{:layoutget/%13ju}{:getdevinfo/%13ju}\n",
718 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_EXCHANGEID],
719 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CREATESESSION],
720 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_DESTROYSESSION],
721 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_DESTROYCLIENT],
722 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LAYOUTGET],
723 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETDEVICEINFO]);
725 xo_emit("{T:LayoutCommit/%13.13s}{T:LayoutReturn/%13.13s}"
726 "{T:ReclaimCompl/%13.13s}{T:ReadDataS/%13.13s}"
727 "{T:WriteDataS/%13.13s}{T:CommitDataS/%13.13s}\n");
728 xo_emit("{:layoutcomit/%13ju}{:layoutreturn/%13ju}"
729 "{:reclaimcompl/%13ju}{:readdatas/%13ju}"
730 "{:writedatas/%13ju}{:commitdatas/%13ju}\n",
731 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LAYOUTCOMMIT],
732 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LAYOUTRETURN],
733 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RECLAIMCOMPL],
734 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_READDS],
735 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_WRITEDS],
736 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_COMMITDS]);
738 xo_emit("{T:OpenLayout/%13.13s}{T:CreateLayout/%13.13s}"
739 "{T:BindConnSess/%13.13s}{T:LookupOpen/%13.13s}"
740 "{T:AppendWrite/%13.13s}\n");
741 xo_emit("{:openlayout/%13ju}{:createlayout/%13ju}"
742 "{:bindconnsess/%13ju}{:lookupopen/%13ju}"
743 "{:appendwrite/%13ju}\n",
744 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_OPENLAYGET],
745 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_CREATELAYGET],
746 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_BINDCONNTOSESS],
747 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LOOKUPOPEN],
748 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_APPENDWRITE]);
750 xo_close_container("nfsv41");
752 xo_open_container("nfsv42");
754 xo_emit("{T:IOAdvise/%13.13s}{T:Allocate/%13.13s}"
755 "{T:Copy/%13.13s}{T:Seek/%13.13s}"
756 "{T:SeekDataS/%13.13s}{T:GetExtattr/%13.13s}\n");
757 xo_emit("{:ioadvise/%13ju}{:allocate/%13ju}"
758 "{:copy/%13ju}{:seek/%13ju}"
759 "{:seekdatas/%13ju}{:getextattr/%13ju}\n",
760 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_IOADVISE],
761 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_ALLOCATE],
762 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_COPY],
763 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SEEK],
764 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SEEKDS],
765 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_GETEXTATTR]);
767 xo_emit("{T:SetExtattr/%13.13s}{T:RmExtattr/%13.13s}"
768 "{T:ListExtattr/%13.13s}{T:Deallocate/%13.13s}"
769 "{T:LayoutError/%13.13s}\n");
770 xo_emit("{:setextattr/%13ju}{:rmextattr/%13ju}"
771 "{:listextattr/%13ju}{:deallocate/%13ju}"
772 "{:layouterror/%13ju}\n",
773 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_SETEXTATTR],
774 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_RMEXTATTR],
775 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LISTEXTATTR],
776 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_DEALLOCATE],
777 (uintmax_t)ext_nfsstats.rpccnt[NFSPROC_LAYOUTERROR]);
779 xo_close_container("nfsv42");
781 xo_close_container("operations");
784 xo_emit("{T:Client:}\n");
785 xo_open_container("client");
786 xo_emit("{T:OpenOwner/%13.13s}{T:Opens/%13.13s}"
787 "{T:LockOwner/%13.13s}{T:Locks/%13.13s}"
788 "{T:Delegs/%13.13s}{T:LocalOwn/%13.13s}\n");
789 xo_emit("{:openowner/%13ju}{:opens/%13ju}"
790 "{:lockowner/%13ju}{:locks/%13ju}"
791 "{:delegs/%13ju}{:localown/%13ju}\n",
792 (uintmax_t)ext_nfsstats.clopenowners,
793 (uintmax_t)ext_nfsstats.clopens,
794 (uintmax_t)ext_nfsstats.cllockowners,
795 (uintmax_t)ext_nfsstats.cllocks,
796 (uintmax_t)ext_nfsstats.cldelegates,
797 (uintmax_t)ext_nfsstats.cllocalopenowners);
799 xo_emit("{T:LocalOpen/%13.13s}{T:LocalLown/%13.13s}"
800 "{T:LocalLock/%13.13s}{T:Layouts/%13.13s}\n");
801 xo_emit("{:localopen/%13ju}{:locallown/%13ju}"
802 "{:locallock/%13ju}{:layouts/%13ju}\n",
803 (uintmax_t)ext_nfsstats.cllocalopens,
804 (uintmax_t)ext_nfsstats.cllocallockowners,
805 (uintmax_t)ext_nfsstats.cllocallocks,
806 (uintmax_t)ext_nfsstats.cllayouts);
807 xo_close_container("client");
809 xo_open_container("rpc");
811 xo_emit("{T:Rpc Info:}\n");
812 xo_emit("{T:TimedOut/%13.13s}{T:Invalid/%13.13s}"
813 "{T:X Replies/%13.13s}{T:Retries/%13.13s}"
814 "{T:Requests/%13.13s}\n");
815 xo_emit("{:timedout/%13ju}{:invalid/%13ju}"
816 "{:xreplies/%13ju}{:retries/%13ju}"
817 "{:requests/%13ju}\n",
818 (uintmax_t)ext_nfsstats.rpctimeouts,
819 (uintmax_t)ext_nfsstats.rpcinvalid,
820 (uintmax_t)ext_nfsstats.rpcunexpected,
821 (uintmax_t)ext_nfsstats.rpcretries,
822 (uintmax_t)ext_nfsstats.rpcrequests);
823 xo_close_container("rpc");
825 xo_open_container("cache");
827 xo_emit("{T:Cache Info:}\n");
828 xo_emit("{T:Attr Hits/%13.13s}{T:Attr Misses/%13.13s}"
829 "{T:Lkup Hits/%13.13s}{T:Lkup Misses/%13.13s}\n");
830 xo_emit("{:attrhits/%13ju}{:attrmisses/%13ju}"
831 "{:lkuphits/%13ju}{:lkupmisses/%13ju}\n",
832 (uintmax_t)ext_nfsstats.attrcache_hits,
833 (uintmax_t)ext_nfsstats.attrcache_misses,
834 (uintmax_t)ext_nfsstats.lookupcache_hits,
835 (uintmax_t)ext_nfsstats.lookupcache_misses);
837 xo_emit("{T:BioR Hits/%13.13s}{T:BioR Misses/%13.13s}"
838 "{T:BioW Hits/%13.13s}{T:BioW Misses/%13.13s}\n");
839 xo_emit("{:biorhits/%13ju}{:biormisses/%13ju}"
840 "{:biowhits/%13ju}{:biowmisses/%13ju}\n",
841 (uintmax_t)(ext_nfsstats.biocache_reads -
842 ext_nfsstats.read_bios),
843 (uintmax_t)ext_nfsstats.read_bios,
844 (uintmax_t)(ext_nfsstats.biocache_writes -
845 ext_nfsstats.write_bios),
846 (uintmax_t)ext_nfsstats.write_bios);
848 xo_emit("{T:BioRL Hits/%13.13s}{T:BioRL Misses/%13.13s}"
849 "{T:BioD Hits/%13.13s}{T:BioD Misses/%13.13s}\n");
850 xo_emit("{:biorlhits/%13ju}{:biorlmisses/%13ju}"
851 "{:biodhits/%13ju}{:biodmisses/%13ju}\n",
852 (uintmax_t)(ext_nfsstats.biocache_readlinks -
853 ext_nfsstats.readlink_bios),
854 (uintmax_t)ext_nfsstats.readlink_bios,
855 (uintmax_t)(ext_nfsstats.biocache_readdirs -
856 ext_nfsstats.readdir_bios),
857 (uintmax_t)ext_nfsstats.readdir_bios);
859 xo_emit("{T:DirE Hits/%13.13s}{T:DirE Misses/%13.13s}\n");
860 xo_emit("{:direhits/%13ju}{:diremisses/%13ju}\n",
861 (uintmax_t)ext_nfsstats.direofcache_hits,
862 (uintmax_t)ext_nfsstats.direofcache_misses);
863 xo_open_container("cache");
865 xo_close_container("clientstats");
867 if (serverOnly != 0) {
868 xo_open_container("serverstats");
870 xo_open_container("operations");
872 xo_emit("{T:Server Info:}\n");
873 xo_emit("{T:Getattr/%13.13s}{T:Setattr/%13.13s}"
874 "{T:Lookup/%13.13s}{T:Readlink/%13.13s}"
875 "{T:Read/%13.13s}{T:Write/%13.13s}\n");
876 xo_emit("{:getattr/%13ju}{:setattr/%13ju}{:lookup/%13ju}"
877 "{:readlink/%13ju}{:read/%13ju}{:write/%13ju}\n",
878 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR],
879 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR],
880 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP],
881 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READLINK],
882 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READ],
883 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITE]);
884 xo_emit("{T:Create/%13.13s}{T:Remove/%13.13s}"
885 "{T:Rename/%13.13s}{T:Link/%13.13s}"
886 "{T:Symlink/%13.13s}{T:Mkdir/%13.13s}\n");
887 xo_emit("{:create/%13ju}{:remove/%13ju}{:rename/%13ju}"
888 "{:link/%13ju}{:symlink/%13ju}{:mkdir/%13ju}\n",
889 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE],
890 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE],
891 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RENAME],
892 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LINK],
893 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK],
894 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR]);
895 xo_emit("{T:Rmdir/%13.13s}{T:Readdir/%13.13s}"
896 "{T:RdirPlus/%13.13s}{T:Access/%13.13s}"
897 "{T:Mknod/%13.13s}{T:Fsstat/%13.13s}\n");
898 xo_emit("{:rmdir/%13ju}{:readdir/%13ju}{:rdirplus/%13ju}"
899 "{:access/%13ju}{:mknod/%13ju}{:fsstat/%13ju}\n",
900 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR],
901 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READDIR],
902 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS],
903 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS],
904 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD],
905 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT]);
906 xo_emit("{T:FSinfo/%13.13s}{T:pathConf/%13.13s}"
907 "{T:Commit/%13.13s}{T:LookupP/%13.13s}"
908 "{T:SetClId/%13.13s}{T:SetClIdCf/%13.13s}\n");
909 xo_emit("{:fsinfo/%13ju}{:pathconf/%13ju}{:commit/%13ju}"
910 "{:lookupp/%13ju}{:setclientid/%13ju}{:setclientidcfrm/%13ju}\n",
911 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO],
912 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF],
913 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT],
914 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP],
915 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID],
916 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]);
917 xo_emit("{T:Open/%13.13s}{T:OpenAttr/%13.13s}"
918 "{T:OpenDwnGr/%13.13s}{T:OpenCfrm/%13.13s}"
919 "{T:DelePurge/%13.13s}{T:DelRet/%13.13s}\n");
920 xo_emit("{:open/%13ju}{:openattr/%13ju}{:opendwgr/%13ju}"
921 "{:opencfrm/%13ju}{:delepurge/%13ju}{:delreg/%13ju}\n",
922 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OPEN],
923 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR],
924 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE],
925 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM],
926 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE],
927 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN]);
928 xo_emit("{T:GetFH/%13.13s}{T:Lock/%13.13s}"
929 "{T:LockT/%13.13s}{T:LockU/%13.13s}"
930 "{T:Close/%13.13s}{T:Verify/%13.13s}\n");
931 xo_emit("{:getfh/%13ju}{:lock/%13ju}{:lockt/%13ju}"
932 "{:locku/%13ju}{:close/%13ju}{:verify/%13ju}\n",
933 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETFH],
934 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOCK],
935 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT],
936 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU],
937 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE],
938 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY]);
939 xo_emit("{T:NVerify/%13.13s}{T:PutFH/%13.13s}"
940 "{T:PutPubFH/%13.13s}{T:PutRootFH/%13.13s}"
941 "{T:Renew/%13.13s}{T:RestoreFH/%13.13s}\n");
942 xo_emit("{:nverify/%13ju}{:putfh/%13ju}{:putpubfh/%13ju}"
943 "{:putrootfh/%13ju}{:renew/%13ju}{:restore/%13ju}\n",
944 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY],
945 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH],
946 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH],
947 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH],
948 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RENEW],
949 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH]);
950 xo_emit("{T:SaveFH/%13.13s}{T:Secinfo/%13.13s}"
951 "{T:RelLockOwn/%13.13s}{T:V4Create/%13.13s}\n");
952 xo_emit("{:savefh/%13ju}{:secinfo/%13ju}{:rellockown/%13ju}"
953 "{:v4create/%13ju}\n",
954 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH],
955 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO],
956 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN],
957 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]);
959 xo_open_container("nfsv41");
960 xo_emit("{T:BackChannelCtrl/%13.13s}{T:BindConnToSess/%13.13s}"
961 "{T:ExchangeID/%13.13s}{T:CreateSess/%13.13s}"
962 "{T:DestroySess/%13.13s}{T:FreeStateID/%13.13s}\n");
963 xo_emit("{:backchannelctrl/%13ju}{:bindconntosess/%13ju}"
964 "{:exchangeid/%13ju}{:createsess/%13ju}"
965 "{:destroysess/%13ju}{:freestateid/%13ju}\n",
966 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_BACKCHANNELCTL],
967 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_BINDCONNTOSESS],
968 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_EXCHANGEID],
969 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_CREATESESSION],
970 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DESTROYSESSION],
971 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_FREESTATEID]),
973 xo_emit("{T:GetDirDeleg/%13.13s}{T:GetDevInfo/%13.13s}"
974 "{T:GetDevList/%13.13s}{T:layoutCommit/%13.13s}"
975 "{T:LayoutGet/%13.13s}{T:LayoutReturn/%13.13s}\n");
976 xo_emit("{:getdirdeleg/%13ju}{:getdevinfo/%13ju}"
977 "{:getdevlist/%13ju}{:layoutcommit/%13ju}"
978 "{:layoutget/%13ju}{:layoutreturn/%13ju}\n",
979 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETDIRDELEG],
980 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETDEVINFO],
981 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETDEVLIST],
982 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTCOMMIT],
983 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTGET],
984 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTRETURN]);
986 xo_emit("{T:SecInfNoName/%13.13s}{T:Sequence/%13.13s}"
987 "{T:SetSSV/%13.13s}{T:TestStateID/%13.13s}"
988 "{T:WantDeleg/%13.13s}{T:DestroyClId/%13.13s}\n");
989 xo_emit("{:secinfnoname/%13ju}{:sequence/%13ju}"
990 "{:setssv/%13ju}{:teststateid/%13ju}{:wantdeleg/%13ju}"
991 "{:destroyclid/%13ju}\n",
992 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SECINFONONAME],
993 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SEQUENCE],
994 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETSSV],
995 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_TESTSTATEID],
996 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WANTDELEG],
997 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DESTROYCLIENTID]);
999 xo_emit("{T:ReclaimCompl/%13.13s}\n");
1000 xo_emit("{:reclaimcompl/%13ju}\n",
1001 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_RECLAIMCOMPL]);
1003 xo_close_container("nfsv41");
1005 xo_open_container("nfsv42");
1007 xo_emit("{T:Allocate/%13.13s}{T:Copy/%13.13s}"
1008 "{T:CopyNotify/%13.13s}{T:Deallocate/%13.13s}"
1009 "{T:IOAdvise/%13.13s}{T:LayoutError/%13.13s}\n");
1010 xo_emit("{:allocate/%13ju}{:copy/%13ju}"
1011 "{:copynotify/%13ju}{:deallocate/%13ju}"
1012 "{:ioadvise/%13ju}{:layouterror/%13ju}\n",
1013 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_ALLOCATE],
1014 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COPY],
1015 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_COPYNOTIFY],
1016 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_DEALLOCATE],
1017 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_IOADVISE],
1018 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTERROR]);
1020 xo_emit("{T:LayoutStats/%13.13s}{T:OffloadCncl/%13.13s}"
1021 "{T:OffloadStat/%13.13s}{T:ReadPlus/%13.13s}"
1022 "{T:Seek/%13.13s}{T:WriteSame/%13.13s}\n");
1023 xo_emit("{:layoutstats/%13ju}{:offloadcncl/%13ju}"
1024 "{:offloadstat/%13ju}{:readplus/%13ju}"
1025 "{:seek/%13ju}{:writesame/%13ju}\n",
1026 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LAYOUTSTATS],
1027 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OFFLOADCANCEL],
1028 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_OFFLOADSTATUS],
1029 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_READPLUS],
1030 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SEEK],
1031 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_WRITESAME]);
1033 xo_emit("{T:Clone/%13.13s}{T:GetExtattr/%13.13s}"
1034 "{T:SetExtattr/%13.13s}{T:ListExtattr/%13.13s}"
1035 "{T:RmExtattr/%13.13s}\n");
1036 xo_emit("{:clone/%13ju}{:getextattr/%13ju}"
1037 "{:setextattr/%13ju}{:listextattr/%13ju}"
1038 "{:rmextattr/%13ju}\n",
1039 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_CLONE],
1040 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_GETXATTR],
1041 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_SETXATTR],
1042 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_LISTXATTRS],
1043 (uintmax_t)ext_nfsstats.srvrpccnt[NFSV4OP_REMOVEXATTR]);
1045 xo_close_container("nfsv42");
1048 xo_close_container("operations");
1051 xo_emit("{T:Server:}\n");
1052 xo_open_container("server");
1053 xo_emit("{T:Clients/%13.13s}{T:OpenOwner/%13.13s}"
1054 "{T:Opens/%13.13s}{T:LockOwner/%13.13s}{T:Locks/%13.13s}"
1055 "{T:Delegs/%13.13s}\n");
1056 xo_emit("{:clients/%13ju}{:openowner/%13ju}{:opens/%13ju}"
1057 "{:lockowner/%13ju}{:locks/%13ju}{:delegs/%13ju}\n",
1058 (uintmax_t)ext_nfsstats.srvclients,
1059 (uintmax_t)ext_nfsstats.srvopenowners,
1060 (uintmax_t)ext_nfsstats.srvopens,
1061 (uintmax_t)ext_nfsstats.srvlockowners,
1062 (uintmax_t)ext_nfsstats.srvlocks,
1063 (uintmax_t)ext_nfsstats.srvdelegates);
1064 xo_emit("{T:Layouts/%13.13s}\n");
1065 xo_emit("{:layouts/%13ju}\n",
1066 (uintmax_t)ext_nfsstats.srvlayouts);
1067 xo_close_container("server");
1070 xo_emit("{T:Server Cache Stats:}\n");
1071 xo_open_container("cache");
1072 xo_emit("{T:Inprog/%13.13s}"
1073 "{T:Non-idem/%13.13s}{T:Misses/%13.13s}"
1074 "{T:CacheSize/%13.13s}{T:TCPPeak/%13.13s}\n");
1075 xo_emit("{:inprog/%13ju}{:nonidem/%13ju}"
1076 "{:misses/%13ju}{:cachesize/%13ju}{:tcppeak/%13ju}\n",
1077 (uintmax_t)ext_nfsstats.srvcache_inproghits,
1078 (uintmax_t)ext_nfsstats.srvcache_nonidemdonehits,
1079 (uintmax_t)ext_nfsstats.srvcache_misses,
1080 (uintmax_t)ext_nfsstats.srvcache_size,
1081 (uintmax_t)ext_nfsstats.srvcache_tcppeak);
1082 xo_close_container("cache");
1084 xo_close_container("serverstats");
1087 xo_close_container("nfsv4");
1091 compute_totals(struct nfsstatsv1 *total_stats, struct nfsstatsv1 *cur_stats)
1095 bzero(total_stats, sizeof(*total_stats));
1096 for (i = 0; i < (NFSV42_NOPS + NFSV4OP_FAKENOPS); i++) {
1097 total_stats->srvbytes[0] += cur_stats->srvbytes[i];
1098 total_stats->srvops[0] += cur_stats->srvops[i];
1099 bintime_add(&total_stats->srvduration[0],
1100 &cur_stats->srvduration[i]);
1101 total_stats->srvrpccnt[i] = cur_stats->srvrpccnt[i];
1103 total_stats->srvstartcnt = cur_stats->srvstartcnt;
1104 total_stats->srvdonecnt = cur_stats->srvdonecnt;
1105 total_stats->busytime = cur_stats->busytime;
1110 * Print a running summary of nfs statistics for the experimental client and/or
1112 * Repeat display every interval seconds, showing statistics
1113 * collected over that interval. Assumes that interval is non-zero.
1114 * First line printed at top of screen is always cumulative.
1117 exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly,
1120 struct nfsstatsv1 nfsstats, lastst, *ext_nfsstatsp;
1121 struct nfsstatsv1 curtotal, lasttotal;
1122 struct timespec ts, lastts;
1125 ext_nfsstatsp = &lastst;
1126 ext_nfsstatsp->vers = NFSSTATS_V1;
1127 if (nfssvc(NFSSVC_GETSTATS | NFSSVC_NEWSTRUCT, ext_nfsstatsp) < 0)
1128 err(1, "Can't get stats");
1129 clock_gettime(CLOCK_MONOTONIC, &lastts);
1130 compute_totals(&lasttotal, ext_nfsstatsp);
1134 ext_nfsstatsp = &nfsstats;
1135 ext_nfsstatsp->vers = NFSSTATS_V1;
1136 if (nfssvc(NFSSVC_GETSTATS | NFSSVC_NEWSTRUCT, ext_nfsstatsp)
1138 err(1, "Can't get stats");
1139 clock_gettime(CLOCK_MONOTONIC, &ts);
1141 if (--hdrcnt == 0) {
1142 printhdr(clientOnly, serverOnly, newStats);
1145 else if (clientOnly && serverOnly)
1150 if (clientOnly && newStats == 0) {
1151 printf("%s %6ju %6ju %6ju %6ju %6ju %6ju %6ju %6ju",
1152 ((clientOnly && serverOnly) ? "Client:" : ""),
1153 (uintmax_t)DELTA(rpccnt[NFSPROC_GETATTR]),
1154 (uintmax_t)DELTA(rpccnt[NFSPROC_LOOKUP]),
1155 (uintmax_t)DELTA(rpccnt[NFSPROC_READLINK]),
1156 (uintmax_t)DELTA(rpccnt[NFSPROC_READ]),
1157 (uintmax_t)DELTA(rpccnt[NFSPROC_WRITE]),
1158 (uintmax_t)DELTA(rpccnt[NFSPROC_RENAME]),
1159 (uintmax_t)DELTA(rpccnt[NFSPROC_ACCESS]),
1160 (uintmax_t)(DELTA(rpccnt[NFSPROC_READDIR]) +
1161 DELTA(rpccnt[NFSPROC_READDIRPLUS]))
1164 printf(" %s %s %s %s %s %s",
1165 sperc1(DELTA(attrcache_hits),
1166 DELTA(attrcache_misses)),
1167 sperc1(DELTA(lookupcache_hits),
1168 DELTA(lookupcache_misses)),
1169 sperc2(DELTA(biocache_reads),
1171 sperc2(DELTA(biocache_writes),
1173 sperc1(DELTA(accesscache_hits),
1174 DELTA(accesscache_misses)),
1175 sperc2(DELTA(biocache_readdirs),
1176 DELTA(readdir_bios))
1182 if (serverOnly && newStats) {
1183 long double cur_secs, last_secs, etime;
1185 long double kb_per_transfer;
1186 long double transfers_per_second;
1187 long double ms_per_transfer;
1189 long double busy_pct;
1192 cur_secs = ts.tv_sec +
1193 ((long double)ts.tv_nsec / 1000000000);
1194 last_secs = lastts.tv_sec +
1195 ((long double)lastts.tv_nsec / 1000000000);
1196 etime = cur_secs - last_secs;
1198 compute_totals(&curtotal, &nfsstats);
1200 for (i = 0; i < NUM_STAT_TYPES; i++) {
1201 compute_new_stats(&nfsstats, &lastst,
1202 STAT_TYPE_TO_NFS(i), etime, &mbsec,
1204 &transfers_per_second,
1205 &ms_per_transfer, &queue_len,
1208 if (i == STAT_TYPE_COMMIT) {
1212 printf("%2.0Lf %7.2Lf ",
1213 transfers_per_second,
1216 printf("%5.2Lf %5.0Lf %7.2Lf ",
1218 transfers_per_second, mbsec);
1225 compute_new_stats(&curtotal, &lasttotal, 0, etime,
1226 &mbsec, &kb_per_transfer, &transfers_per_second,
1227 &ms_per_transfer, &queue_len, &busy_pct);
1229 printf("%5.2Lf %5.0Lf %7.2Lf %5.2Lf %3ju %3.0Lf\n",
1230 kb_per_transfer, transfers_per_second, mbsec,
1231 ms_per_transfer, queue_len, busy_pct);
1232 } else if (serverOnly) {
1233 printf("%s %6ju %6ju %6ju %6ju %6ju %6ju %6ju %6ju",
1234 ((clientOnly && serverOnly) ? "Server:" : ""),
1235 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_GETATTR]),
1236 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_LOOKUP]),
1237 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_READLINK]),
1238 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_READ]),
1239 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_WRITE]),
1240 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_RENAME]),
1241 (uintmax_t)DELTA(srvrpccnt[NFSV4OP_ACCESS]),
1242 (uintmax_t)(DELTA(srvrpccnt[NFSV4OP_READDIR]) +
1243 DELTA(srvrpccnt[NFSV4OP_READDIRPLUS])));
1246 bcopy(&nfsstats, &lastst, sizeof(lastst));
1247 bcopy(&curtotal, &lasttotal, sizeof(lasttotal));