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. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static const char copyright[] =
39 "@(#) Copyright (c) 1983, 1989, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
45 static char sccsid[] = "@(#)nfsstat.c 8.2 (Berkeley) 3/31/95";
47 static const char rcsid[] =
51 #include <sys/param.h>
52 #include <sys/module.h>
53 #include <sys/mount.h>
55 #include <sys/sysctl.h>
56 #include <nfs/nfsproto.h>
57 #include <nfsclient/nfs.h>
58 #include <nfsserver/nfs.h>
59 #include <nfs/nfssvc.h>
61 #include <fs/nfs/nfsport.h>
79 { .n_name = "nfsstats" },
81 { .n_name = "nfsrvstats" },
86 static int deadkernel = 0;
87 static int widemode = 0;
89 static int run_v4 = 0;
90 static int printtitle = 1;
91 static struct ext_nfsstats ext_nfsstats;
94 void printhdr(int, int);
95 void sidewaysintpr(u_int, int, int);
97 char *sperc1(int, int);
98 char *sperc2(int, int);
99 void exp_intpr(int, int);
100 void exp_sidewaysintpr(u_int, int, int);
102 #define DELTA(field) (nfsstats.field - lastst.field)
105 main(int argc, char **argv)
112 char errbuf[_POSIX2_LINE_MAX];
115 memf = nlistf = NULL;
116 while ((ch = getopt(argc, argv, "cesWM:N:w:z")) != -1)
128 interval = atoi(optarg);
153 #define BACKWARD_COMPATIBILITY
154 #ifdef BACKWARD_COMPATIBILITY
156 interval = atoi(*argv);
164 if (run_v4 != 0 && modfind("nfscommon") < 0)
165 errx(1, "experimental client/server not loaded");
167 if (run_v4 == 0 && (nlistf != NULL || memf != NULL)) {
170 if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
172 errx(1, "kvm_openfiles: %s", errbuf);
174 if (kvm_nlist(kd, nl) != 0) {
175 errx(1, "kvm_nlist: can't get names");
181 exp_sidewaysintpr(interval, clientOnly, serverOnly);
183 sidewaysintpr(interval, clientOnly, serverOnly);
186 exp_intpr(clientOnly, serverOnly);
188 intpr(clientOnly, serverOnly);
194 * Read the nfs stats using sysctl(3) for live kernels, or kvm_read
198 readstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero)
201 struct nfsstats client;
202 struct nfsrvstats server;
207 if (*stp != NULL && kvm_read(kd, (u_long)nl[N_NFSSTAT].n_value,
208 *stp, sizeof(struct nfsstats)) < 0) {
211 if (*srvstp != NULL && kvm_read(kd,
212 (u_long)nl[N_NFSRVSTAT].n_value, *srvstp,
213 sizeof(struct nfsrvstats)) < 0) {
218 bzero(&zerostat, sizeof(zerostat));
219 buflen = sizeof(struct nfsstats);
220 if (*stp != NULL && sysctlbyname("vfs.nfs.nfsstats", *stp,
221 &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) {
223 err(1, "sysctl: vfs.nfs.nfsstats");
226 buflen = sizeof(struct nfsrvstats);
227 if (*srvstp != NULL && sysctlbyname("vfs.nfsrv.nfsrvstats",
228 *srvstp, &buflen, zero ? &zerostat : NULL,
229 zero ? buflen : 0) < 0) {
231 err(1, "sysctl: vfs.nfsrv.nfsrvstats");
238 * Print a description of the nfs stats.
241 intpr(int clientOnly, int serverOnly)
243 struct nfsstats nfsstats, *nfsstatsp;
244 struct nfsrvstats nfsrvstats, *nfsrvstatsp;
247 * Only read the stats we are going to display to avoid zeroing
248 * stats the user didn't request.
251 nfsstatsp = &nfsstats;
255 nfsrvstatsp = &nfsrvstats;
259 readstats(&nfsstatsp, &nfsrvstatsp, zflag);
261 if (clientOnly && !nfsstatsp) {
262 printf("Client not present!\n");
266 printf("Client Info:\n");
267 printf("Rpc Counts:\n");
268 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
269 "Getattr", "Setattr", "Lookup", "Readlink", "Read",
270 "Write", "Create", "Remove");
271 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
272 nfsstats.rpccnt[NFSPROC_GETATTR],
273 nfsstats.rpccnt[NFSPROC_SETATTR],
274 nfsstats.rpccnt[NFSPROC_LOOKUP],
275 nfsstats.rpccnt[NFSPROC_READLINK],
276 nfsstats.rpccnt[NFSPROC_READ],
277 nfsstats.rpccnt[NFSPROC_WRITE],
278 nfsstats.rpccnt[NFSPROC_CREATE],
279 nfsstats.rpccnt[NFSPROC_REMOVE]);
280 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
281 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
282 "Readdir", "RdirPlus", "Access");
283 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
284 nfsstats.rpccnt[NFSPROC_RENAME],
285 nfsstats.rpccnt[NFSPROC_LINK],
286 nfsstats.rpccnt[NFSPROC_SYMLINK],
287 nfsstats.rpccnt[NFSPROC_MKDIR],
288 nfsstats.rpccnt[NFSPROC_RMDIR],
289 nfsstats.rpccnt[NFSPROC_READDIR],
290 nfsstats.rpccnt[NFSPROC_READDIRPLUS],
291 nfsstats.rpccnt[NFSPROC_ACCESS]);
292 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
293 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
294 printf("%9d %9d %9d %9d %9d\n",
295 nfsstats.rpccnt[NFSPROC_MKNOD],
296 nfsstats.rpccnt[NFSPROC_FSSTAT],
297 nfsstats.rpccnt[NFSPROC_FSINFO],
298 nfsstats.rpccnt[NFSPROC_PATHCONF],
299 nfsstats.rpccnt[NFSPROC_COMMIT]);
300 printf("Rpc Info:\n");
301 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
302 "TimedOut", "Invalid", "X Replies", "Retries",
304 printf("%9d %9d %9d %9d %9d\n",
305 nfsstats.rpctimeouts,
307 nfsstats.rpcunexpected,
309 nfsstats.rpcrequests);
310 printf("Cache Info:\n");
311 printf("%9.9s %9.9s %9.9s %9.9s",
312 "Attr Hits", "Misses", "Lkup Hits", "Misses");
313 printf(" %9.9s %9.9s %9.9s %9.9s\n",
314 "BioR Hits", "Misses", "BioW Hits", "Misses");
315 printf("%9d %9d %9d %9d",
316 nfsstats.attrcache_hits, nfsstats.attrcache_misses,
317 nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
318 printf(" %9d %9d %9d %9d\n",
319 nfsstats.biocache_reads-nfsstats.read_bios,
321 nfsstats.biocache_writes-nfsstats.write_bios,
322 nfsstats.write_bios);
323 printf("%9.9s %9.9s %9.9s %9.9s",
324 "BioRLHits", "Misses", "BioD Hits", "Misses");
325 printf(" %9.9s %9.9s %9.9s %9.9s\n", "DirE Hits", "Misses", "Accs Hits", "Misses");
326 printf("%9d %9d %9d %9d",
327 nfsstats.biocache_readlinks-nfsstats.readlink_bios,
328 nfsstats.readlink_bios,
329 nfsstats.biocache_readdirs-nfsstats.readdir_bios,
330 nfsstats.readdir_bios);
331 printf(" %9d %9d %9d %9d\n",
332 nfsstats.direofcache_hits, nfsstats.direofcache_misses,
333 nfsstats.accesscache_hits, nfsstats.accesscache_misses);
335 if (serverOnly && !nfsrvstatsp) {
336 printf("Server not present!\n");
340 printf("\nServer Info:\n");
341 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
342 "Getattr", "Setattr", "Lookup", "Readlink", "Read",
343 "Write", "Create", "Remove");
344 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
345 nfsrvstats.srvrpccnt[NFSPROC_GETATTR],
346 nfsrvstats.srvrpccnt[NFSPROC_SETATTR],
347 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP],
348 nfsrvstats.srvrpccnt[NFSPROC_READLINK],
349 nfsrvstats.srvrpccnt[NFSPROC_READ],
350 nfsrvstats.srvrpccnt[NFSPROC_WRITE],
351 nfsrvstats.srvrpccnt[NFSPROC_CREATE],
352 nfsrvstats.srvrpccnt[NFSPROC_REMOVE]);
353 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
354 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
355 "Readdir", "RdirPlus", "Access");
356 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
357 nfsrvstats.srvrpccnt[NFSPROC_RENAME],
358 nfsrvstats.srvrpccnt[NFSPROC_LINK],
359 nfsrvstats.srvrpccnt[NFSPROC_SYMLINK],
360 nfsrvstats.srvrpccnt[NFSPROC_MKDIR],
361 nfsrvstats.srvrpccnt[NFSPROC_RMDIR],
362 nfsrvstats.srvrpccnt[NFSPROC_READDIR],
363 nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS],
364 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]);
365 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
366 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
367 printf("%9d %9d %9d %9d %9d\n",
368 nfsrvstats.srvrpccnt[NFSPROC_MKNOD],
369 nfsrvstats.srvrpccnt[NFSPROC_FSSTAT],
370 nfsrvstats.srvrpccnt[NFSPROC_FSINFO],
371 nfsrvstats.srvrpccnt[NFSPROC_PATHCONF],
372 nfsrvstats.srvrpccnt[NFSPROC_COMMIT]);
373 printf("Server Ret-Failed\n");
374 printf("%17d\n", nfsrvstats.srvrpc_errs);
375 printf("Server Faults\n");
376 printf("%13d\n", nfsrvstats.srv_errs);
377 printf("Server Cache Stats:\n");
378 printf("%9.9s %9.9s %9.9s %9.9s\n",
379 "Inprog", "Idem", "Non-idem", "Misses");
380 printf("%9d %9d %9d %9d\n",
381 nfsrvstats.srvcache_inproghits,
382 nfsrvstats.srvcache_idemdonehits,
383 nfsrvstats.srvcache_nonidemdonehits,
384 nfsrvstats.srvcache_misses);
385 printf("Server Write Gathering:\n");
386 printf("%9.9s %9.9s %9.9s\n",
387 "WriteOps", "WriteRPC", "Opsaved");
388 printf("%9d %9d %9d\n",
389 nfsrvstats.srvvop_writes,
390 nfsrvstats.srvrpccnt[NFSPROC_WRITE],
391 nfsrvstats.srvrpccnt[NFSPROC_WRITE] -
392 nfsrvstats.srvvop_writes);
396 u_char signalled; /* set if alarm goes off "early" */
399 * Print a running summary of nfs statistics.
400 * Repeat display every interval seconds, showing statistics
401 * collected over that interval. Assumes that interval is non-zero.
402 * First line printed at top of screen is always cumulative.
405 sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
407 struct nfsstats nfsstats, lastst, *nfsstatsp;
408 struct nfsrvstats nfsrvstats, lastsrvst, *nfsrvstatsp;
412 nfsrvstatsp = &lastsrvst;
413 readstats(&nfsstatsp, &nfsrvstatsp, 0);
414 if (clientOnly && !nfsstatsp) {
415 printf("Client not present!\n");
418 if (serverOnly && !nfsrvstatsp) {
419 printf("Server not present!\n");
425 nfsstatsp = &nfsstats;
426 nfsrvstatsp = &nfsrvstats;
427 readstats(&nfsstatsp, &nfsrvstatsp, 0);
430 printhdr(clientOnly, serverOnly);
431 if (clientOnly && serverOnly)
437 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
438 ((clientOnly && serverOnly) ? "Client:" : ""),
439 DELTA(rpccnt[NFSPROC_GETATTR]),
440 DELTA(rpccnt[NFSPROC_LOOKUP]),
441 DELTA(rpccnt[NFSPROC_READLINK]),
442 DELTA(rpccnt[NFSPROC_READ]),
443 DELTA(rpccnt[NFSPROC_WRITE]),
444 DELTA(rpccnt[NFSPROC_RENAME]),
445 DELTA(rpccnt[NFSPROC_ACCESS]),
446 DELTA(rpccnt[NFSPROC_READDIR]) +
447 DELTA(rpccnt[NFSPROC_READDIRPLUS])
450 printf(" %s %s %s %s %s %s",
451 sperc1(DELTA(attrcache_hits),
452 DELTA(attrcache_misses)),
453 sperc1(DELTA(lookupcache_hits),
454 DELTA(lookupcache_misses)),
455 sperc2(DELTA(biocache_reads),
457 sperc2(DELTA(biocache_writes),
459 sperc1(DELTA(accesscache_hits),
460 DELTA(accesscache_misses)),
461 sperc2(DELTA(biocache_readdirs),
469 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
470 ((clientOnly && serverOnly) ? "Server:" : ""),
471 nfsrvstats.srvrpccnt[NFSPROC_GETATTR]-lastsrvst.srvrpccnt[NFSPROC_GETATTR],
472 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP]-lastsrvst.srvrpccnt[NFSPROC_LOOKUP],
473 nfsrvstats.srvrpccnt[NFSPROC_READLINK]-lastsrvst.srvrpccnt[NFSPROC_READLINK],
474 nfsrvstats.srvrpccnt[NFSPROC_READ]-lastsrvst.srvrpccnt[NFSPROC_READ],
475 nfsrvstats.srvrpccnt[NFSPROC_WRITE]-lastsrvst.srvrpccnt[NFSPROC_WRITE],
476 nfsrvstats.srvrpccnt[NFSPROC_RENAME]-lastsrvst.srvrpccnt[NFSPROC_RENAME],
477 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]-lastsrvst.srvrpccnt[NFSPROC_ACCESS],
478 (nfsrvstats.srvrpccnt[NFSPROC_READDIR]-lastsrvst.srvrpccnt[NFSPROC_READDIR])
479 +(nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastsrvst.srvrpccnt[NFSPROC_READDIRPLUS]));
481 lastsrvst = nfsrvstats;
490 printhdr(int clientOnly, int serverOnly)
492 printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
493 ((serverOnly && clientOnly) ? " " : " "),
494 "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename",
496 if (widemode && clientOnly) {
497 printf(" Attr Lkup BioR BioW Accs BioD");
506 (void)fprintf(stderr,
507 "usage: nfsstat [-ceszW] [-M core] [-N system] [-w interval]\n");
511 static char SPBuf[64][8];
515 sperc1(int hits, int misses)
517 char *p = SPBuf[SPIndex];
521 (int)(char)((quad_t)hits * 100 / (hits + misses)));
525 SPIndex = (SPIndex + 1) & 63;
530 sperc2(int ttl, int misses)
532 char *p = SPBuf[SPIndex];
536 (int)(char)((quad_t)(ttl - misses) * 100 / ttl));
540 SPIndex = (SPIndex + 1) & 63;
545 * Print a description of the nfs stats for the experimental client/server.
548 exp_intpr(int clientOnly, int serverOnly)
552 nfssvc_flag = NFSSVC_GETSTATS;
555 nfssvc_flag |= NFSSVC_ZEROCLTSTATS;
557 nfssvc_flag |= NFSSVC_ZEROSRVSTATS;
559 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0)
560 err(1, "Can't get stats");
561 if (clientOnly != 0) {
563 printf("Client Info:\n");
564 printf("Rpc Counts:\n");
566 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
567 , "Getattr", "Setattr", "Lookup", "Readlink",
568 "Read", "Write", "Create", "Remove");
570 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
571 ext_nfsstats.rpccnt[NFSPROC_GETATTR],
572 ext_nfsstats.rpccnt[NFSPROC_SETATTR],
573 ext_nfsstats.rpccnt[NFSPROC_LOOKUP],
574 ext_nfsstats.rpccnt[NFSPROC_READLINK],
575 ext_nfsstats.rpccnt[NFSPROC_READ],
576 ext_nfsstats.rpccnt[NFSPROC_WRITE],
577 ext_nfsstats.rpccnt[NFSPROC_CREATE],
578 ext_nfsstats.rpccnt[NFSPROC_REMOVE]);
581 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
582 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
583 "Readdir", "RdirPlus", "Access");
584 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
585 ext_nfsstats.rpccnt[NFSPROC_RENAME],
586 ext_nfsstats.rpccnt[NFSPROC_LINK],
587 ext_nfsstats.rpccnt[NFSPROC_SYMLINK],
588 ext_nfsstats.rpccnt[NFSPROC_MKDIR],
589 ext_nfsstats.rpccnt[NFSPROC_RMDIR],
590 ext_nfsstats.rpccnt[NFSPROC_READDIR],
591 ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS],
592 ext_nfsstats.rpccnt[NFSPROC_ACCESS]);
595 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
596 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
597 "Commit", "SetClId", "SetClIdCf", "Lock");
598 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
599 ext_nfsstats.rpccnt[NFSPROC_MKNOD],
600 ext_nfsstats.rpccnt[NFSPROC_FSSTAT],
601 ext_nfsstats.rpccnt[NFSPROC_FSINFO],
602 ext_nfsstats.rpccnt[NFSPROC_PATHCONF],
603 ext_nfsstats.rpccnt[NFSPROC_COMMIT],
604 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID],
605 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM],
606 ext_nfsstats.rpccnt[NFSPROC_LOCK]);
608 printf("%9.9s %9.9s %9.9s %9.9s\n",
609 "LockT", "LockU", "Open", "OpenCfr");
610 printf("%9d %9d %9d %9d\n",
611 ext_nfsstats.rpccnt[NFSPROC_LOCKT],
612 ext_nfsstats.rpccnt[NFSPROC_LOCKU],
613 ext_nfsstats.rpccnt[NFSPROC_OPEN],
614 ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]);
617 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
618 , "OpenOwner", "Opens", "LockOwner",
619 "Locks", "Delegs", "LocalOwn",
620 "LocalOpen", "LocalLOwn");
621 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
622 ext_nfsstats.clopenowners,
623 ext_nfsstats.clopens,
624 ext_nfsstats.cllockowners,
625 ext_nfsstats.cllocks,
626 ext_nfsstats.cldelegates,
627 ext_nfsstats.cllocalopenowners,
628 ext_nfsstats.cllocalopens,
629 ext_nfsstats.cllocallockowners);
631 printf("%9.9s\n", "LocalLock");
632 printf("%9d\n", ext_nfsstats.cllocallocks);
634 printf("Rpc Info:\n");
635 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
636 "TimedOut", "Invalid", "X Replies", "Retries",
639 printf("%9d %9d %9d %9d %9d\n",
640 ext_nfsstats.rpctimeouts,
641 ext_nfsstats.rpcinvalid,
642 ext_nfsstats.rpcunexpected,
643 ext_nfsstats.rpcretries,
644 ext_nfsstats.rpcrequests);
646 printf("Cache Info:\n");
647 printf("%9.9s %9.9s %9.9s %9.9s",
648 "Attr Hits", "Misses", "Lkup Hits", "Misses");
649 printf(" %9.9s %9.9s %9.9s %9.9s\n",
650 "BioR Hits", "Misses", "BioW Hits", "Misses");
652 printf("%9d %9d %9d %9d",
653 ext_nfsstats.attrcache_hits,
654 ext_nfsstats.attrcache_misses,
655 ext_nfsstats.lookupcache_hits,
656 ext_nfsstats.lookupcache_misses);
657 printf(" %9d %9d %9d %9d\n",
658 ext_nfsstats.biocache_reads - ext_nfsstats.read_bios,
659 ext_nfsstats.read_bios,
660 ext_nfsstats.biocache_writes - ext_nfsstats.write_bios,
661 ext_nfsstats.write_bios);
663 printf("%9.9s %9.9s %9.9s %9.9s",
664 "BioRLHits", "Misses", "BioD Hits", "Misses");
665 printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
667 printf("%9d %9d %9d %9d",
668 ext_nfsstats.biocache_readlinks -
669 ext_nfsstats.readlink_bios,
670 ext_nfsstats.readlink_bios,
671 ext_nfsstats.biocache_readdirs -
672 ext_nfsstats.readdir_bios,
673 ext_nfsstats.readdir_bios);
675 ext_nfsstats.direofcache_hits,
676 ext_nfsstats.direofcache_misses);
678 if (serverOnly != 0) {
680 printf("\nServer Info:\n");
682 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
683 , "Getattr", "Setattr", "Lookup", "Readlink",
684 "Read", "Write", "Create", "Remove");
686 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
687 ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR],
688 ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR],
689 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP],
690 ext_nfsstats.srvrpccnt[NFSV4OP_READLINK],
691 ext_nfsstats.srvrpccnt[NFSV4OP_READ],
692 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE],
693 ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE],
694 ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]);
697 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
698 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
699 "Readdir", "RdirPlus", "Access");
700 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
701 ext_nfsstats.srvrpccnt[NFSV4OP_RENAME],
702 ext_nfsstats.srvrpccnt[NFSV4OP_LINK],
703 ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK],
704 ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR],
705 ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR],
706 ext_nfsstats.srvrpccnt[NFSV4OP_READDIR],
707 ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS],
708 ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]);
711 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
712 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
713 "Commit", "LookupP", "SetClId", "SetClIdCf");
714 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
715 ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD],
716 ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT],
717 ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO],
718 ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF],
719 ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT],
720 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP],
721 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID],
722 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]);
725 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
726 , "Open", "OpenAttr", "OpenDwnGr", "OpenCfrm",
727 "DelePurge", "DeleRet", "GetFH", "Lock");
728 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
729 ext_nfsstats.srvrpccnt[NFSV4OP_OPEN],
730 ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR],
731 ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE],
732 ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM],
733 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE],
734 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN],
735 ext_nfsstats.srvrpccnt[NFSV4OP_GETFH],
736 ext_nfsstats.srvrpccnt[NFSV4OP_LOCK]);
739 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
740 , "LockT", "LockU", "Close", "Verify", "NVerify",
741 "PutFH", "PutPubFH", "PutRootFH");
742 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
743 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT],
744 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU],
745 ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE],
746 ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY],
747 ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY],
748 ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH],
749 ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH],
750 ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH]);
752 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
753 "Renew", "RestoreFH", "SaveFH", "Secinfo",
754 "RelLckOwn", "V4Create");
755 printf("%9d %9d %9d %9d %9d %9d\n",
756 ext_nfsstats.srvrpccnt[NFSV4OP_RENEW],
757 ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH],
758 ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH],
759 ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO],
760 ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN],
761 ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]);
764 printf("%9.9s %9.9s %9.9s\n",
765 "Retfailed", "Faults", "Clients");
767 printf("%9d %9d %9d\n",
768 ext_nfsstats.srv_errs, ext_nfsstats.srvrpc_errs,
769 ext_nfsstats.srvclients);
771 printf("%9.9s %9.9s %9.9s %9.9s %9.9s \n",
772 "OpenOwner", "Opens", "LockOwner",
774 printf("%9d %9d %9d %9d %9d \n",
775 ext_nfsstats.srvopenowners,
776 ext_nfsstats.srvopens,
777 ext_nfsstats.srvlockowners,
778 ext_nfsstats.srvlocks,
779 ext_nfsstats.srvdelegates);
781 printf("Server Cache Stats:\n");
782 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
783 "Inprog", "Idem", "Non-idem", "Misses",
784 "CacheSize", "TCPPeak");
786 printf("%9d %9d %9d %9d %9d %9d\n",
787 ext_nfsstats.srvcache_inproghits,
788 ext_nfsstats.srvcache_idemdonehits,
789 ext_nfsstats.srvcache_nonidemdonehits,
790 ext_nfsstats.srvcache_misses,
791 ext_nfsstats.srvcache_size,
792 ext_nfsstats.srvcache_tcppeak);
797 * Print a running summary of nfs statistics for the experimental client and/or
799 * Repeat display every interval seconds, showing statistics
800 * collected over that interval. Assumes that interval is non-zero.
801 * First line printed at top of screen is always cumulative.
804 exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
806 struct ext_nfsstats nfsstats, lastst, *ext_nfsstatsp;
809 ext_nfsstatsp = &lastst;
810 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
811 err(1, "Can't get stats");
815 ext_nfsstatsp = &nfsstats;
816 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
817 err(1, "Can't get stats");
820 printhdr(clientOnly, serverOnly);
821 if (clientOnly && serverOnly)
827 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
828 ((clientOnly && serverOnly) ? "Client:" : ""),
829 DELTA(rpccnt[NFSPROC_GETATTR]),
830 DELTA(rpccnt[NFSPROC_LOOKUP]),
831 DELTA(rpccnt[NFSPROC_READLINK]),
832 DELTA(rpccnt[NFSPROC_READ]),
833 DELTA(rpccnt[NFSPROC_WRITE]),
834 DELTA(rpccnt[NFSPROC_RENAME]),
835 DELTA(rpccnt[NFSPROC_ACCESS]),
836 DELTA(rpccnt[NFSPROC_READDIR]) +
837 DELTA(rpccnt[NFSPROC_READDIRPLUS])
840 printf(" %s %s %s %s %s %s",
841 sperc1(DELTA(attrcache_hits),
842 DELTA(attrcache_misses)),
843 sperc1(DELTA(lookupcache_hits),
844 DELTA(lookupcache_misses)),
845 sperc2(DELTA(biocache_reads),
847 sperc2(DELTA(biocache_writes),
849 sperc1(DELTA(accesscache_hits),
850 DELTA(accesscache_misses)),
851 sperc2(DELTA(biocache_readdirs),
859 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
860 ((clientOnly && serverOnly) ? "Server:" : ""),
861 DELTA(srvrpccnt[NFSV4OP_GETATTR]),
862 DELTA(srvrpccnt[NFSV4OP_LOOKUP]),
863 DELTA(srvrpccnt[NFSV4OP_READLINK]),
864 DELTA(srvrpccnt[NFSV4OP_READ]),
865 DELTA(srvrpccnt[NFSV4OP_WRITE]),
866 DELTA(srvrpccnt[NFSV4OP_RENAME]),
867 DELTA(srvrpccnt[NFSV4OP_ACCESS]),
868 DELTA(srvrpccnt[NFSV4OP_READDIR]) +
869 DELTA(srvrpccnt[NFSV4OP_READDIRPLUS]));