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");
168 if (nfssvc(NFSSVC_GETSTATS, &ext_nfsstats) < 0)
169 err(1, "Can't get stats");
170 } else if (nlistf != NULL || memf != NULL) {
173 if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
175 errx(1, "kvm_openfiles: %s", errbuf);
177 if (kvm_nlist(kd, nl) != 0) {
178 errx(1, "kvm_nlist: can't get names");
184 exp_sidewaysintpr(interval, clientOnly, serverOnly);
186 sidewaysintpr(interval, clientOnly, serverOnly);
189 exp_intpr(clientOnly, serverOnly);
191 intpr(clientOnly, serverOnly);
197 * Read the nfs stats using sysctl(3) for live kernels, or kvm_read
201 readstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero)
204 struct nfsstats client;
205 struct nfsrvstats server;
210 if (*stp != NULL && kvm_read(kd, (u_long)nl[N_NFSSTAT].n_value,
211 *stp, sizeof(struct nfsstats)) < 0) {
214 if (*srvstp != NULL && kvm_read(kd,
215 (u_long)nl[N_NFSRVSTAT].n_value, *srvstp,
216 sizeof(struct nfsrvstats)) < 0) {
221 bzero(&zerostat, sizeof(zerostat));
222 buflen = sizeof(struct nfsstats);
223 if (*stp != NULL && sysctlbyname("vfs.nfs.nfsstats", *stp,
224 &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) {
226 err(1, "sysctl: vfs.nfs.nfsstats");
229 buflen = sizeof(struct nfsrvstats);
230 if (*srvstp != NULL && sysctlbyname("vfs.nfsrv.nfsrvstats",
231 *srvstp, &buflen, zero ? &zerostat : NULL,
232 zero ? buflen : 0) < 0) {
234 err(1, "sysctl: vfs.nfsrv.nfsrvstats");
241 * Print a description of the nfs stats.
244 intpr(int clientOnly, int serverOnly)
246 struct nfsstats nfsstats, *nfsstatsp;
247 struct nfsrvstats nfsrvstats, *nfsrvstatsp;
250 * Only read the stats we are going to display to avoid zeroing
251 * stats the user didn't request.
254 nfsstatsp = &nfsstats;
258 nfsrvstatsp = &nfsrvstats;
262 readstats(&nfsstatsp, &nfsrvstatsp, zflag);
264 if (clientOnly && !nfsstatsp) {
265 printf("Client not present!\n");
269 printf("Client Info:\n");
270 printf("Rpc Counts:\n");
271 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
272 "Getattr", "Setattr", "Lookup", "Readlink", "Read",
273 "Write", "Create", "Remove");
274 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
275 nfsstats.rpccnt[NFSPROC_GETATTR],
276 nfsstats.rpccnt[NFSPROC_SETATTR],
277 nfsstats.rpccnt[NFSPROC_LOOKUP],
278 nfsstats.rpccnt[NFSPROC_READLINK],
279 nfsstats.rpccnt[NFSPROC_READ],
280 nfsstats.rpccnt[NFSPROC_WRITE],
281 nfsstats.rpccnt[NFSPROC_CREATE],
282 nfsstats.rpccnt[NFSPROC_REMOVE]);
283 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
284 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
285 "Readdir", "RdirPlus", "Access");
286 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
287 nfsstats.rpccnt[NFSPROC_RENAME],
288 nfsstats.rpccnt[NFSPROC_LINK],
289 nfsstats.rpccnt[NFSPROC_SYMLINK],
290 nfsstats.rpccnt[NFSPROC_MKDIR],
291 nfsstats.rpccnt[NFSPROC_RMDIR],
292 nfsstats.rpccnt[NFSPROC_READDIR],
293 nfsstats.rpccnt[NFSPROC_READDIRPLUS],
294 nfsstats.rpccnt[NFSPROC_ACCESS]);
295 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
296 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
297 printf("%9d %9d %9d %9d %9d\n",
298 nfsstats.rpccnt[NFSPROC_MKNOD],
299 nfsstats.rpccnt[NFSPROC_FSSTAT],
300 nfsstats.rpccnt[NFSPROC_FSINFO],
301 nfsstats.rpccnt[NFSPROC_PATHCONF],
302 nfsstats.rpccnt[NFSPROC_COMMIT]);
303 printf("Rpc Info:\n");
304 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
305 "TimedOut", "Invalid", "X Replies", "Retries",
307 printf("%9d %9d %9d %9d %9d\n",
308 nfsstats.rpctimeouts,
310 nfsstats.rpcunexpected,
312 nfsstats.rpcrequests);
313 printf("Cache Info:\n");
314 printf("%9.9s %9.9s %9.9s %9.9s",
315 "Attr Hits", "Misses", "Lkup Hits", "Misses");
316 printf(" %9.9s %9.9s %9.9s %9.9s\n",
317 "BioR Hits", "Misses", "BioW Hits", "Misses");
318 printf("%9d %9d %9d %9d",
319 nfsstats.attrcache_hits, nfsstats.attrcache_misses,
320 nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
321 printf(" %9d %9d %9d %9d\n",
322 nfsstats.biocache_reads-nfsstats.read_bios,
324 nfsstats.biocache_writes-nfsstats.write_bios,
325 nfsstats.write_bios);
326 printf("%9.9s %9.9s %9.9s %9.9s",
327 "BioRLHits", "Misses", "BioD Hits", "Misses");
328 printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
329 printf("%9d %9d %9d %9d",
330 nfsstats.biocache_readlinks-nfsstats.readlink_bios,
331 nfsstats.readlink_bios,
332 nfsstats.biocache_readdirs-nfsstats.readdir_bios,
333 nfsstats.readdir_bios);
335 nfsstats.direofcache_hits, nfsstats.direofcache_misses);
337 if (serverOnly && !nfsrvstatsp) {
338 printf("Server not present!\n");
342 printf("\nServer Info:\n");
343 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
344 "Getattr", "Setattr", "Lookup", "Readlink", "Read",
345 "Write", "Create", "Remove");
346 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
347 nfsrvstats.srvrpccnt[NFSPROC_GETATTR],
348 nfsrvstats.srvrpccnt[NFSPROC_SETATTR],
349 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP],
350 nfsrvstats.srvrpccnt[NFSPROC_READLINK],
351 nfsrvstats.srvrpccnt[NFSPROC_READ],
352 nfsrvstats.srvrpccnt[NFSPROC_WRITE],
353 nfsrvstats.srvrpccnt[NFSPROC_CREATE],
354 nfsrvstats.srvrpccnt[NFSPROC_REMOVE]);
355 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
356 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
357 "Readdir", "RdirPlus", "Access");
358 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
359 nfsrvstats.srvrpccnt[NFSPROC_RENAME],
360 nfsrvstats.srvrpccnt[NFSPROC_LINK],
361 nfsrvstats.srvrpccnt[NFSPROC_SYMLINK],
362 nfsrvstats.srvrpccnt[NFSPROC_MKDIR],
363 nfsrvstats.srvrpccnt[NFSPROC_RMDIR],
364 nfsrvstats.srvrpccnt[NFSPROC_READDIR],
365 nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS],
366 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]);
367 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
368 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
369 printf("%9d %9d %9d %9d %9d\n",
370 nfsrvstats.srvrpccnt[NFSPROC_MKNOD],
371 nfsrvstats.srvrpccnt[NFSPROC_FSSTAT],
372 nfsrvstats.srvrpccnt[NFSPROC_FSINFO],
373 nfsrvstats.srvrpccnt[NFSPROC_PATHCONF],
374 nfsrvstats.srvrpccnt[NFSPROC_COMMIT]);
375 printf("Server Ret-Failed\n");
376 printf("%17d\n", nfsrvstats.srvrpc_errs);
377 printf("Server Faults\n");
378 printf("%13d\n", nfsrvstats.srv_errs);
379 printf("Server Cache Stats:\n");
380 printf("%9.9s %9.9s %9.9s %9.9s\n",
381 "Inprog", "Idem", "Non-idem", "Misses");
382 printf("%9d %9d %9d %9d\n",
383 nfsrvstats.srvcache_inproghits,
384 nfsrvstats.srvcache_idemdonehits,
385 nfsrvstats.srvcache_nonidemdonehits,
386 nfsrvstats.srvcache_misses);
387 printf("Server Write Gathering:\n");
388 printf("%9.9s %9.9s %9.9s\n",
389 "WriteOps", "WriteRPC", "Opsaved");
390 printf("%9d %9d %9d\n",
391 nfsrvstats.srvvop_writes,
392 nfsrvstats.srvrpccnt[NFSPROC_WRITE],
393 nfsrvstats.srvrpccnt[NFSPROC_WRITE] -
394 nfsrvstats.srvvop_writes);
398 u_char signalled; /* set if alarm goes off "early" */
401 * Print a running summary of nfs statistics.
402 * Repeat display every interval seconds, showing statistics
403 * collected over that interval. Assumes that interval is non-zero.
404 * First line printed at top of screen is always cumulative.
407 sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
409 struct nfsstats nfsstats, lastst, *nfsstatsp;
410 struct nfsrvstats nfsrvstats, lastsrvst, *nfsrvstatsp;
414 nfsrvstatsp = &lastsrvst;
415 readstats(&nfsstatsp, &nfsrvstatsp, 0);
416 if (clientOnly && !nfsstatsp) {
417 printf("Client not present!\n");
420 if (serverOnly && !nfsrvstatsp) {
421 printf("Server not present!\n");
427 nfsstatsp = &nfsstats;
428 nfsrvstatsp = &nfsrvstats;
429 readstats(&nfsstatsp, &nfsrvstatsp, 0);
432 printhdr(clientOnly, serverOnly);
433 if (clientOnly && serverOnly)
439 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
440 ((clientOnly && serverOnly) ? "Client:" : ""),
441 DELTA(attrcache_hits) + DELTA(attrcache_misses),
442 DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
443 DELTA(biocache_readlinks),
444 DELTA(biocache_reads),
445 DELTA(biocache_writes),
446 nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME],
447 DELTA(accesscache_hits) + DELTA(accesscache_misses),
448 DELTA(biocache_readdirs)
451 printf(" %s %s %s %s %s %s",
452 sperc1(DELTA(attrcache_hits),
453 DELTA(attrcache_misses)),
454 sperc1(DELTA(lookupcache_hits),
455 DELTA(lookupcache_misses)),
456 sperc2(DELTA(biocache_reads),
458 sperc2(DELTA(biocache_writes),
460 sperc1(DELTA(accesscache_hits),
461 DELTA(accesscache_misses)),
462 sperc2(DELTA(biocache_readdirs),
470 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
471 ((clientOnly && serverOnly) ? "Server:" : ""),
472 nfsrvstats.srvrpccnt[NFSPROC_GETATTR]-lastsrvst.srvrpccnt[NFSPROC_GETATTR],
473 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP]-lastsrvst.srvrpccnt[NFSPROC_LOOKUP],
474 nfsrvstats.srvrpccnt[NFSPROC_READLINK]-lastsrvst.srvrpccnt[NFSPROC_READLINK],
475 nfsrvstats.srvrpccnt[NFSPROC_READ]-lastsrvst.srvrpccnt[NFSPROC_READ],
476 nfsrvstats.srvrpccnt[NFSPROC_WRITE]-lastsrvst.srvrpccnt[NFSPROC_WRITE],
477 nfsrvstats.srvrpccnt[NFSPROC_RENAME]-lastsrvst.srvrpccnt[NFSPROC_RENAME],
478 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]-lastsrvst.srvrpccnt[NFSPROC_ACCESS],
479 (nfsrvstats.srvrpccnt[NFSPROC_READDIR]-lastsrvst.srvrpccnt[NFSPROC_READDIR])
480 +(nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastsrvst.srvrpccnt[NFSPROC_READDIRPLUS]));
482 lastsrvst = nfsrvstats;
491 printhdr(int clientOnly, int serverOnly)
493 printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
494 ((serverOnly && clientOnly) ? " " : " "),
495 "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename",
497 if (widemode && clientOnly) {
498 printf(" Attr Lkup BioR BioW Accs BioD");
507 (void)fprintf(stderr,
508 "usage: nfsstat [-ceszW] [-M core] [-N system] [-w interval]\n");
512 static char SPBuf[64][8];
516 sperc1(int hits, int misses)
518 char *p = SPBuf[SPIndex];
522 (int)(char)((quad_t)hits * 100 / (hits + misses)));
526 SPIndex = (SPIndex + 1) & 63;
531 sperc2(int ttl, int misses)
533 char *p = SPBuf[SPIndex];
537 (int)(char)((quad_t)(ttl - misses) * 100 / ttl));
541 SPIndex = (SPIndex + 1) & 63;
546 * Print a description of the nfs stats for the experimental client/server.
549 exp_intpr(int clientOnly, int serverOnly)
552 if (clientOnly != 0) {
554 printf("Client Info:\n");
555 printf("Rpc Counts:\n");
557 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
558 , "Getattr", "Setattr", "Lookup", "Readlink",
559 "Read", "Write", "Create", "Remove");
561 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
562 ext_nfsstats.rpccnt[NFSPROC_GETATTR],
563 ext_nfsstats.rpccnt[NFSPROC_SETATTR],
564 ext_nfsstats.rpccnt[NFSPROC_LOOKUP],
565 ext_nfsstats.rpccnt[NFSPROC_READLINK],
566 ext_nfsstats.rpccnt[NFSPROC_READ],
567 ext_nfsstats.rpccnt[NFSPROC_WRITE],
568 ext_nfsstats.rpccnt[NFSPROC_CREATE],
569 ext_nfsstats.rpccnt[NFSPROC_REMOVE]);
572 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
573 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
574 "Readdir", "RdirPlus", "Access");
575 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
576 ext_nfsstats.rpccnt[NFSPROC_RENAME],
577 ext_nfsstats.rpccnt[NFSPROC_LINK],
578 ext_nfsstats.rpccnt[NFSPROC_SYMLINK],
579 ext_nfsstats.rpccnt[NFSPROC_MKDIR],
580 ext_nfsstats.rpccnt[NFSPROC_RMDIR],
581 ext_nfsstats.rpccnt[NFSPROC_READDIR],
582 ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS],
583 ext_nfsstats.rpccnt[NFSPROC_ACCESS]);
586 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
587 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
588 "Commit", "SetClId", "SetClIdCf", "Lock");
589 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
590 ext_nfsstats.rpccnt[NFSPROC_MKNOD],
591 ext_nfsstats.rpccnt[NFSPROC_FSSTAT],
592 ext_nfsstats.rpccnt[NFSPROC_FSINFO],
593 ext_nfsstats.rpccnt[NFSPROC_PATHCONF],
594 ext_nfsstats.rpccnt[NFSPROC_COMMIT],
595 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID],
596 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM],
597 ext_nfsstats.rpccnt[NFSPROC_LOCK]);
599 printf("%9.9s %9.9s %9.9s %9.9s\n",
600 "LockT", "LockU", "Open", "OpenCfr");
601 printf("%9d %9d %9d %9d\n",
602 ext_nfsstats.rpccnt[NFSPROC_LOCKT],
603 ext_nfsstats.rpccnt[NFSPROC_LOCKU],
604 ext_nfsstats.rpccnt[NFSPROC_OPEN],
605 ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]);
608 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
609 , "OpenOwner", "Opens", "LockOwner",
610 "Locks", "Delegs", "LocalOwn",
611 "LocalOpen", "LocalLOwn");
612 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
613 ext_nfsstats.clopenowners,
614 ext_nfsstats.clopens,
615 ext_nfsstats.cllockowners,
616 ext_nfsstats.cllocks,
617 ext_nfsstats.cldelegates,
618 ext_nfsstats.cllocalopenowners,
619 ext_nfsstats.cllocalopens,
620 ext_nfsstats.cllocallockowners);
622 printf("%9.9s\n", "LocalLock");
623 printf("%9d\n", ext_nfsstats.cllocallocks);
625 printf("Rpc Info:\n");
626 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
627 "TimedOut", "Invalid", "X Replies", "Retries",
630 printf("%9d %9d %9d %9d %9d\n",
631 ext_nfsstats.rpctimeouts,
632 ext_nfsstats.rpcinvalid,
633 ext_nfsstats.rpcunexpected,
634 ext_nfsstats.rpcretries,
635 ext_nfsstats.rpcrequests);
637 printf("Cache Info:\n");
638 printf("%9.9s %9.9s %9.9s %9.9s",
639 "Attr Hits", "Misses", "Lkup Hits", "Misses");
640 printf(" %9.9s %9.9s %9.9s %9.9s\n",
641 "BioR Hits", "Misses", "BioW Hits", "Misses");
643 printf("%9d %9d %9d %9d",
644 ext_nfsstats.attrcache_hits,
645 ext_nfsstats.attrcache_misses,
646 ext_nfsstats.lookupcache_hits,
647 ext_nfsstats.lookupcache_misses);
648 printf(" %9d %9d %9d %9d\n",
649 ext_nfsstats.biocache_reads,
650 ext_nfsstats.read_bios,
651 ext_nfsstats.biocache_writes,
652 ext_nfsstats.write_bios);
654 printf("%9.9s %9.9s %9.9s %9.9s",
655 "BioRLHits", "Misses", "BioD Hits", "Misses");
656 printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
658 printf("%9d %9d %9d %9d",
659 ext_nfsstats.biocache_readlinks,
660 ext_nfsstats.readlink_bios,
661 ext_nfsstats.biocache_readdirs,
662 ext_nfsstats.readdir_bios);
664 ext_nfsstats.direofcache_hits,
665 ext_nfsstats.direofcache_misses);
667 if (serverOnly != 0) {
669 printf("\nServer Info:\n");
671 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
672 , "Getattr", "Setattr", "Lookup", "Readlink",
673 "Read", "Write", "Create", "Remove");
675 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
676 ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR],
677 ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR],
678 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP],
679 ext_nfsstats.srvrpccnt[NFSV4OP_READLINK],
680 ext_nfsstats.srvrpccnt[NFSV4OP_READ],
681 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE],
682 ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE],
683 ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]);
686 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
687 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
688 "Readdir", "RdirPlus", "Access");
689 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
690 ext_nfsstats.srvrpccnt[NFSV4OP_RENAME],
691 ext_nfsstats.srvrpccnt[NFSV4OP_LINK],
692 ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK],
693 ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR],
694 ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR],
695 ext_nfsstats.srvrpccnt[NFSV4OP_READDIR],
696 ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS],
697 ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]);
700 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
701 , "Mknod", "Fsstat", "Fsinfo", "PathConf",
702 "Commit", "LookupP", "SetClId", "SetClIdCf");
703 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
704 ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD],
705 ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT],
706 ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO],
707 ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF],
708 ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT],
709 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP],
710 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID],
711 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]);
714 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
715 , "Open", "OpenAttr", "OpenDwnGr", "OpenCfrm",
716 "DelePurge", "DeleRet", "GetFH", "Lock");
717 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
718 ext_nfsstats.srvrpccnt[NFSV4OP_OPEN],
719 ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR],
720 ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE],
721 ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM],
722 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE],
723 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN],
724 ext_nfsstats.srvrpccnt[NFSV4OP_GETFH],
725 ext_nfsstats.srvrpccnt[NFSV4OP_LOCK]);
728 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n"
729 , "LockT", "LockU", "Close", "Verify", "NVerify",
730 "PutFH", "PutPubFH", "PutRootFH");
731 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
732 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT],
733 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU],
734 ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE],
735 ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY],
736 ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY],
737 ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH],
738 ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH],
739 ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH]);
741 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
742 "Renew", "RestoreFH", "SaveFH", "Secinfo",
743 "RelLckOwn", "V4Create");
744 printf("%9d %9d %9d %9d %9d %9d\n",
745 ext_nfsstats.srvrpccnt[NFSV4OP_RENEW],
746 ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH],
747 ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH],
748 ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO],
749 ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN],
750 ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]);
753 printf("%9.9s %9.9s %9.9s\n",
754 "Retfailed", "Faults", "Clients");
756 printf("%9d %9d %9d\n",
757 ext_nfsstats.srv_errs, ext_nfsstats.srvrpc_errs,
758 ext_nfsstats.srvclients);
760 printf("%9.9s %9.9s %9.9s %9.9s %9.9s \n",
761 "OpenOwner", "Opens", "LockOwner",
763 printf("%9d %9d %9d %9d %9d \n",
764 ext_nfsstats.srvopenowners,
765 ext_nfsstats.srvopens,
766 ext_nfsstats.srvlockowners,
767 ext_nfsstats.srvlocks,
768 ext_nfsstats.srvdelegates);
770 printf("Server Cache Stats:\n");
771 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
772 "Inprog", "Idem", "Non-idem", "Misses",
773 "CacheSize", "TCPPeak");
775 printf("%9d %9d %9d %9d %9d %9d\n",
776 ext_nfsstats.srvcache_inproghits,
777 ext_nfsstats.srvcache_idemdonehits,
778 ext_nfsstats.srvcache_nonidemdonehits,
779 ext_nfsstats.srvcache_misses,
780 ext_nfsstats.srvcache_size,
781 ext_nfsstats.srvcache_tcppeak);
786 * Print a running summary of nfs statistics for the experimental client and/or
788 * Repeat display every interval seconds, showing statistics
789 * collected over that interval. Assumes that interval is non-zero.
790 * First line printed at top of screen is always cumulative.
793 exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
795 struct ext_nfsstats nfsstats, lastst, *ext_nfsstatsp;
798 ext_nfsstatsp = &lastst;
799 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
800 err(1, "Can't get stats");
804 ext_nfsstatsp = &nfsstats;
805 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0)
806 err(1, "Can't get stats");
809 printhdr(clientOnly, serverOnly);
810 if (clientOnly && serverOnly)
816 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
817 ((clientOnly && serverOnly) ? "Client:" : ""),
818 DELTA(attrcache_hits) + DELTA(attrcache_misses),
819 DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
820 DELTA(biocache_readlinks),
821 DELTA(biocache_reads),
822 DELTA(biocache_writes),
823 nfsstats.rpccnt[NFSPROC_RENAME] -
824 lastst.rpccnt[NFSPROC_RENAME],
825 DELTA(accesscache_hits) + DELTA(accesscache_misses),
826 DELTA(biocache_readdirs)
829 printf(" %s %s %s %s %s %s",
830 sperc1(DELTA(attrcache_hits),
831 DELTA(attrcache_misses)),
832 sperc1(DELTA(lookupcache_hits),
833 DELTA(lookupcache_misses)),
834 sperc2(DELTA(biocache_reads),
836 sperc2(DELTA(biocache_writes),
838 sperc1(DELTA(accesscache_hits),
839 DELTA(accesscache_misses)),
840 sperc2(DELTA(biocache_readdirs),
848 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
849 ((clientOnly && serverOnly) ? "Server:" : ""),
850 nfsstats.srvrpccnt[NFSPROC_GETATTR] -
851 lastst.srvrpccnt[NFSPROC_GETATTR],
852 nfsstats.srvrpccnt[NFSPROC_LOOKUP] -
853 lastst.srvrpccnt[NFSPROC_LOOKUP],
854 nfsstats.srvrpccnt[NFSPROC_READLINK] -
855 lastst.srvrpccnt[NFSPROC_READLINK],
856 nfsstats.srvrpccnt[NFSPROC_READ] -
857 lastst.srvrpccnt[NFSPROC_READ],
858 nfsstats.srvrpccnt[NFSPROC_WRITE] -
859 lastst.srvrpccnt[NFSPROC_WRITE],
860 nfsstats.srvrpccnt[NFSPROC_RENAME] -
861 lastst.srvrpccnt[NFSPROC_RENAME],
862 nfsstats.srvrpccnt[NFSPROC_ACCESS] -
863 lastst.srvrpccnt[NFSPROC_ACCESS],
864 (nfsstats.srvrpccnt[NFSPROC_READDIR] -
865 lastst.srvrpccnt[NFSPROC_READDIR]) +
866 (nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] -
867 lastst.srvrpccnt[NFSPROC_READDIRPLUS]));