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(attrcache_hits) + DELTA(attrcache_misses),
440 DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
441 DELTA(biocache_readlinks),
442 DELTA(biocache_reads),
443 DELTA(biocache_writes),
444 nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME],
445 DELTA(accesscache_hits) + DELTA(accesscache_misses),
446 DELTA(biocache_readdirs)
449 printf(" %s %s %s %s %s %s",
450 sperc1(DELTA(attrcache_hits),
451 DELTA(attrcache_misses)),
452 sperc1(DELTA(lookupcache_hits),
453 DELTA(lookupcache_misses)),
454 sperc2(DELTA(biocache_reads),
456 sperc2(DELTA(biocache_writes),
458 sperc1(DELTA(accesscache_hits),
459 DELTA(accesscache_misses)),
460 sperc2(DELTA(biocache_readdirs),
468 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
469 ((clientOnly && serverOnly) ? "Server:" : ""),
470 nfsrvstats.srvrpccnt[NFSPROC_GETATTR]-lastsrvst.srvrpccnt[NFSPROC_GETATTR],
471 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP]-lastsrvst.srvrpccnt[NFSPROC_LOOKUP],
472 nfsrvstats.srvrpccnt[NFSPROC_READLINK]-lastsrvst.srvrpccnt[NFSPROC_READLINK],
473 nfsrvstats.srvrpccnt[NFSPROC_READ]-lastsrvst.srvrpccnt[NFSPROC_READ],
474 nfsrvstats.srvrpccnt[NFSPROC_WRITE]-lastsrvst.srvrpccnt[NFSPROC_WRITE],
475 nfsrvstats.srvrpccnt[NFSPROC_RENAME]-lastsrvst.srvrpccnt[NFSPROC_RENAME],
476 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]-lastsrvst.srvrpccnt[NFSPROC_ACCESS],
477 (nfsrvstats.srvrpccnt[NFSPROC_READDIR]-lastsrvst.srvrpccnt[NFSPROC_READDIR])
478 +(nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastsrvst.srvrpccnt[NFSPROC_READDIRPLUS]));
480 lastsrvst = nfsrvstats;
489 printhdr(int clientOnly, int serverOnly)
491 printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
492 ((serverOnly && clientOnly) ? " " : " "),
493 "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename",
495 if (widemode && clientOnly) {
496 printf(" Attr Lkup BioR BioW Accs BioD");
505 (void)fprintf(stderr,
506 "usage: nfsstat [-ceszW] [-M core] [-N system] [-w interval]\n");
510 static char SPBuf[64][8];
514 sperc1(int hits, int misses)
516 char *p = SPBuf[SPIndex];
520 (int)(char)((quad_t)hits * 100 / (hits + misses)));
524 SPIndex = (SPIndex + 1) & 63;
529 sperc2(int ttl, int misses)
531 char *p = SPBuf[SPIndex];
535 (int)(char)((quad_t)(ttl - misses) * 100 / ttl));
539 SPIndex = (SPIndex + 1) & 63;
544 * Print a description of the nfs stats for the experimental client/server.
547 exp_intpr(int clientOnly, int serverOnly)
551 nfssvc_flag = NFSSVC_GETSTATS;
554 nfssvc_flag |= NFSSVC_ZEROCLTSTATS;
556 nfssvc_flag |= NFSSVC_ZEROSRVSTATS;
558 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0)
559 err(1, "Can't get stats");
560 if (clientOnly != 0) {
562 printf("Client Info:\n");
563 printf("Rpc Counts:\n");
565 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
566 , "Getattr", "Setattr", "Lookup", "Readlink",
567 "Read", "Write", "Create", "Remove");
569 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
570 ext_nfsstats.rpccnt[NFSPROC_GETATTR],
571 ext_nfsstats.rpccnt[NFSPROC_SETATTR],
572 ext_nfsstats.rpccnt[NFSPROC_LOOKUP],
573 ext_nfsstats.rpccnt[NFSPROC_READLINK],
574 ext_nfsstats.rpccnt[NFSPROC_READ],
575 ext_nfsstats.rpccnt[NFSPROC_WRITE],
576 ext_nfsstats.rpccnt[NFSPROC_CREATE],
577 ext_nfsstats.rpccnt[NFSPROC_REMOVE]);
580 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
581 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
582 "Readdir", "RdirPlus", "Access");
583 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
584 ext_nfsstats.rpccnt[NFSPROC_RENAME],
585 ext_nfsstats.rpccnt[NFSPROC_LINK],
586 ext_nfsstats.rpccnt[NFSPROC_SYMLINK],
587 ext_nfsstats.rpccnt[NFSPROC_MKDIR],
588 ext_nfsstats.rpccnt[NFSPROC_RMDIR],
589 ext_nfsstats.rpccnt[NFSPROC_READDIR],
590 ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS],
591 ext_nfsstats.rpccnt[NFSPROC_ACCESS]);
594 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
595 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
596 "Commit", "SetClId", "SetClIdCf", "Lock");
597 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
598 ext_nfsstats.rpccnt[NFSPROC_MKNOD],
599 ext_nfsstats.rpccnt[NFSPROC_FSSTAT],
600 ext_nfsstats.rpccnt[NFSPROC_FSINFO],
601 ext_nfsstats.rpccnt[NFSPROC_PATHCONF],
602 ext_nfsstats.rpccnt[NFSPROC_COMMIT],
603 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID],
604 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM],
605 ext_nfsstats.rpccnt[NFSPROC_LOCK]);
607 printf("%9.9s %9.9s %9.9s %9.9s\n",
608 "LockT", "LockU", "Open", "OpenCfr");
609 printf("%9d %9d %9d %9d\n",
610 ext_nfsstats.rpccnt[NFSPROC_LOCKT],
611 ext_nfsstats.rpccnt[NFSPROC_LOCKU],
612 ext_nfsstats.rpccnt[NFSPROC_OPEN],
613 ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]);
616 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
617 , "OpenOwner", "Opens", "LockOwner",
618 "Locks", "Delegs", "LocalOwn",
619 "LocalOpen", "LocalLOwn");
620 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
621 ext_nfsstats.clopenowners,
622 ext_nfsstats.clopens,
623 ext_nfsstats.cllockowners,
624 ext_nfsstats.cllocks,
625 ext_nfsstats.cldelegates,
626 ext_nfsstats.cllocalopenowners,
627 ext_nfsstats.cllocalopens,
628 ext_nfsstats.cllocallockowners);
630 printf("%9.9s\n", "LocalLock");
631 printf("%9d\n", ext_nfsstats.cllocallocks);
633 printf("Rpc Info:\n");
634 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
635 "TimedOut", "Invalid", "X Replies", "Retries",
638 printf("%9d %9d %9d %9d %9d\n",
639 ext_nfsstats.rpctimeouts,
640 ext_nfsstats.rpcinvalid,
641 ext_nfsstats.rpcunexpected,
642 ext_nfsstats.rpcretries,
643 ext_nfsstats.rpcrequests);
645 printf("Cache Info:\n");
646 printf("%9.9s %9.9s %9.9s %9.9s",
647 "Attr Hits", "Misses", "Lkup Hits", "Misses");
648 printf(" %9.9s %9.9s %9.9s %9.9s\n",
649 "BioR Hits", "Misses", "BioW Hits", "Misses");
651 printf("%9d %9d %9d %9d",
652 ext_nfsstats.attrcache_hits,
653 ext_nfsstats.attrcache_misses,
654 ext_nfsstats.lookupcache_hits,
655 ext_nfsstats.lookupcache_misses);
656 printf(" %9d %9d %9d %9d\n",
657 ext_nfsstats.biocache_reads - ext_nfsstats.read_bios,
658 ext_nfsstats.read_bios,
659 ext_nfsstats.biocache_writes - ext_nfsstats.write_bios,
660 ext_nfsstats.write_bios);
662 printf("%9.9s %9.9s %9.9s %9.9s",
663 "BioRLHits", "Misses", "BioD Hits", "Misses");
664 printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
666 printf("%9d %9d %9d %9d",
667 ext_nfsstats.biocache_readlinks -
668 ext_nfsstats.readlink_bios,
669 ext_nfsstats.readlink_bios,
670 ext_nfsstats.biocache_readdirs -
671 ext_nfsstats.readdir_bios,
672 ext_nfsstats.readdir_bios);
674 ext_nfsstats.direofcache_hits,
675 ext_nfsstats.direofcache_misses);
677 if (serverOnly != 0) {
679 printf("\nServer Info:\n");
681 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
682 , "Getattr", "Setattr", "Lookup", "Readlink",
683 "Read", "Write", "Create", "Remove");
685 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
686 ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR],
687 ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR],
688 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP],
689 ext_nfsstats.srvrpccnt[NFSV4OP_READLINK],
690 ext_nfsstats.srvrpccnt[NFSV4OP_READ],
691 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE],
692 ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE],
693 ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]);
696 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
697 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
698 "Readdir", "RdirPlus", "Access");
699 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
700 ext_nfsstats.srvrpccnt[NFSV4OP_RENAME],
701 ext_nfsstats.srvrpccnt[NFSV4OP_LINK],
702 ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK],
703 ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR],
704 ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR],
705 ext_nfsstats.srvrpccnt[NFSV4OP_READDIR],
706 ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS],
707 ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]);
710 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
711 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
712 "Commit", "LookupP", "SetClId", "SetClIdCf");
713 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
714 ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD],
715 ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT],
716 ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO],
717 ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF],
718 ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT],
719 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP],
720 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID],
721 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]);
724 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
725 , "Open", "OpenAttr", "OpenDwnGr", "OpenCfrm",
726 "DelePurge", "DeleRet", "GetFH", "Lock");
727 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
728 ext_nfsstats.srvrpccnt[NFSV4OP_OPEN],
729 ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR],
730 ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE],
731 ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM],
732 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE],
733 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN],
734 ext_nfsstats.srvrpccnt[NFSV4OP_GETFH],
735 ext_nfsstats.srvrpccnt[NFSV4OP_LOCK]);
738 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
739 , "LockT", "LockU", "Close", "Verify", "NVerify",
740 "PutFH", "PutPubFH", "PutRootFH");
741 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
742 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT],
743 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU],
744 ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE],
745 ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY],
746 ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY],
747 ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH],
748 ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH],
749 ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH]);
751 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
752 "Renew", "RestoreFH", "SaveFH", "Secinfo",
753 "RelLckOwn", "V4Create");
754 printf("%9d %9d %9d %9d %9d %9d\n",
755 ext_nfsstats.srvrpccnt[NFSV4OP_RENEW],
756 ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH],
757 ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH],
758 ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO],
759 ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN],
760 ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]);
763 printf("%9.9s %9.9s %9.9s\n",
764 "Retfailed", "Faults", "Clients");
766 printf("%9d %9d %9d\n",
767 ext_nfsstats.srv_errs, ext_nfsstats.srvrpc_errs,
768 ext_nfsstats.srvclients);
770 printf("%9.9s %9.9s %9.9s %9.9s %9.9s \n",
771 "OpenOwner", "Opens", "LockOwner",
773 printf("%9d %9d %9d %9d %9d \n",
774 ext_nfsstats.srvopenowners,
775 ext_nfsstats.srvopens,
776 ext_nfsstats.srvlockowners,
777 ext_nfsstats.srvlocks,
778 ext_nfsstats.srvdelegates);
780 printf("Server Cache Stats:\n");
781 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
782 "Inprog", "Idem", "Non-idem", "Misses",
783 "CacheSize", "TCPPeak");
785 printf("%9d %9d %9d %9d %9d %9d\n",
786 ext_nfsstats.srvcache_inproghits,
787 ext_nfsstats.srvcache_idemdonehits,
788 ext_nfsstats.srvcache_nonidemdonehits,
789 ext_nfsstats.srvcache_misses,
790 ext_nfsstats.srvcache_size,
791 ext_nfsstats.srvcache_tcppeak);
796 * Print a running summary of nfs statistics for the experimental client and/or
798 * Repeat display every interval seconds, showing statistics
799 * collected over that interval. Assumes that interval is non-zero.
800 * First line printed at top of screen is always cumulative.
803 exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
805 struct ext_nfsstats nfsstats, lastst, *ext_nfsstatsp;
808 ext_nfsstatsp = &lastst;
809 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
810 err(1, "Can't get stats");
814 ext_nfsstatsp = &nfsstats;
815 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
816 err(1, "Can't get stats");
819 printhdr(clientOnly, serverOnly);
820 if (clientOnly && serverOnly)
826 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
827 ((clientOnly && serverOnly) ? "Client:" : ""),
828 DELTA(attrcache_hits) + DELTA(attrcache_misses),
829 DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
830 DELTA(biocache_readlinks),
831 DELTA(biocache_reads),
832 DELTA(biocache_writes),
833 nfsstats.rpccnt[NFSPROC_RENAME] -
834 lastst.rpccnt[NFSPROC_RENAME],
835 DELTA(accesscache_hits) + DELTA(accesscache_misses),
836 DELTA(biocache_readdirs)
839 printf(" %s %s %s %s %s %s",
840 sperc1(DELTA(attrcache_hits),
841 DELTA(attrcache_misses)),
842 sperc1(DELTA(lookupcache_hits),
843 DELTA(lookupcache_misses)),
844 sperc2(DELTA(biocache_reads),
846 sperc2(DELTA(biocache_writes),
848 sperc1(DELTA(accesscache_hits),
849 DELTA(accesscache_misses)),
850 sperc2(DELTA(biocache_readdirs),
858 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
859 ((clientOnly && serverOnly) ? "Server:" : ""),
860 nfsstats.srvrpccnt[NFSPROC_GETATTR] -
861 lastst.srvrpccnt[NFSPROC_GETATTR],
862 nfsstats.srvrpccnt[NFSPROC_LOOKUP] -
863 lastst.srvrpccnt[NFSPROC_LOOKUP],
864 nfsstats.srvrpccnt[NFSPROC_READLINK] -
865 lastst.srvrpccnt[NFSPROC_READLINK],
866 nfsstats.srvrpccnt[NFSPROC_READ] -
867 lastst.srvrpccnt[NFSPROC_READ],
868 nfsstats.srvrpccnt[NFSPROC_WRITE] -
869 lastst.srvrpccnt[NFSPROC_WRITE],
870 nfsstats.srvrpccnt[NFSPROC_RENAME] -
871 lastst.srvrpccnt[NFSPROC_RENAME],
872 nfsstats.srvrpccnt[NFSPROC_ACCESS] -
873 lastst.srvrpccnt[NFSPROC_ACCESS],
874 (nfsstats.srvrpccnt[NFSPROC_READDIR] -
875 lastst.srvrpccnt[NFSPROC_READDIR]) +
876 (nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] -
877 lastst.srvrpccnt[NFSPROC_READDIRPLUS]));