nfsstat.c revision 221454
1107665Simp/* 2209583Simp * Copyright (c) 1983, 1989, 1993 3107665Simp * The Regents of the University of California. All rights reserved. 4107665Simp * 5107665Simp * This code is derived from software contributed to Berkeley by 6107665Simp * Rick Macklem at The University of Guelph. 7107665Simp * 8107665Simp * Redistribution and use in source and binary forms, with or without 9107665Simp * modification, are permitted provided that the following conditions 10107665Simp * are met: 11107665Simp * 1. Redistributions of source code must retain the above copyright 12107665Simp * notice, this list of conditions and the following disclaimer. 13107665Simp * 2. Redistributions in binary form must reproduce the above copyright 14107665Simp * notice, this list of conditions and the following disclaimer in the 15107665Simp * documentation and/or other materials provided with the distribution. 16107665Simp * 4. Neither the name of the University nor the names of its contributors 17107665Simp * may be used to endorse or promote products derived from this software 18107665Simp * without specific prior written permission. 19107665Simp * 20107665Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21107665Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22107665Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23107665Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24107665Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25209583Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26209583Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27209583Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28209583Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29209583Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30209583Simp * SUCH DAMAGE. 31209583Simp */ 32209583Simp 33209583Simp#ifndef lint 34209583Simpstatic const char copyright[] = 35209583Simp"@(#) Copyright (c) 1983, 1989, 1993\n\ 36209583Simp The Regents of the University of California. All rights reserved.\n"; 37209583Simp#endif /* not lint */ 38209583Simp 39209583Simp#ifndef lint 40209583Simp#if 0 41209583Simpstatic char sccsid[] = "@(#)nfsstat.c 8.2 (Berkeley) 3/31/95"; 42209583Simp#endif 43209583Simpstatic const char rcsid[] = 44209583Simp "$FreeBSD: head/usr.bin/nfsstat/nfsstat.c 221454 2011-05-04 19:28:44Z rmacklem $"; 45209583Simp#endif /* not lint */ 46209583Simp 47209583Simp#include <sys/param.h> 48209583Simp#include <sys/module.h> 49209583Simp#include <sys/mount.h> 50209583Simp#include <sys/time.h> 51209583Simp#include <sys/sysctl.h> 52209583Simp#include <nfs/nfsproto.h> 53209583Simp#include <nfsclient/nfs.h> 54107665Simp#include <nfsserver/nfs.h> 55107665Simp#include <nfs/nfssvc.h> 56107665Simp 57107665Simp#include <fs/nfs/nfsport.h> 58107665Simp 59107665Simp#include <signal.h> 60107665Simp#include <fcntl.h> 61107665Simp#include <ctype.h> 62131397Simp#include <errno.h> 63107665Simp#include <kvm.h> 64107665Simp#include <limits.h> 65107665Simp#include <nlist.h> 66107665Simp#include <unistd.h> 67107665Simp#include <stdio.h> 68107665Simp#include <stdlib.h> 69131397Simp#include <string.h> 70131397Simp#include <paths.h> 71131397Simp#include <err.h> 72107665Simp 73209583Simpstruct nlist nl[] = { 74131397Simp#define N_NFSSTAT 0 75107665Simp { .n_name = "nfsstats" }, 76108014Simp#define N_NFSRVSTAT 1 77107665Simp { .n_name = "nfsrvstats" }, 78107665Simp { .n_name = NULL }, 79107665Simp}; 80107665Simpkvm_t *kd; 81155073Spjd 82209583Simpstatic int deadkernel = 0; 83247576Sianstatic int widemode = 0; 84108014Simpstatic int zflag = 0; 85146306Simpstatic int run_v4 = 0; 86107665Simpstatic int printtitle = 1; 87107665Simpstatic struct ext_nfsstats ext_nfsstats; 88107665Simp 89107665Simpvoid intpr(int, int); 90107665Simpvoid printhdr(int, int); 91108783Simpvoid sidewaysintpr(u_int, int, int); 92107665Simpvoid usage(void); 93107665Simpchar *sperc1(int, int); 94131397Simpchar *sperc2(int, int); 95107665Simpvoid exp_intpr(int, int); 96107665Simpvoid exp_sidewaysintpr(u_int, int, int); 97114086Simp 98114086Simp#define DELTA(field) (nfsstats.field - lastst.field) 99107665Simp 100131397Simpint 101107665Simpmain(int argc, char **argv) 102113787Simp{ 103107665Simp u_int interval; 104107665Simp int clientOnly = -1; 105107665Simp int serverOnly = -1; 106107665Simp int ch; 107107665Simp char *memf, *nlistf; 108107665Simp char errbuf[_POSIX2_LINE_MAX]; 109121487Simp 110108783Simp interval = 0; 111108783Simp memf = nlistf = NULL; 112108783Simp while ((ch = getopt(argc, argv, "cesWM:N:w:z")) != -1) 113108783Simp switch(ch) { 114155073Spjd case 'M': 115155073Spjd memf = optarg; 116113790Simp break; 117107665Simp case 'N': 118114000Simp nlistf = optarg; 119107665Simp break; 120107665Simp case 'W': 121152770Sjkoshy widemode = 1; 122152770Sjkoshy break; 123107665Simp case 'w': 124107665Simp interval = atoi(optarg); 125107665Simp break; 126108783Simp case 'c': 127108783Simp clientOnly = 1; 128108783Simp if (serverOnly < 0) 129108783Simp serverOnly = 0; 130108783Simp break; 131246270Seadler case 's': 132108783Simp serverOnly = 1; 133108783Simp if (clientOnly < 0) 134108783Simp clientOnly = 0; 135108783Simp break; 136107665Simp case 'z': 137107665Simp zflag = 1; 138107665Simp break; 139107665Simp case 'e': 140107665Simp run_v4 = 1; 141107665Simp break; 142107665Simp case '?': 143107665Simp default: 144107665Simp usage(); 145152406Sbland } 146107665Simp argc -= optind; 147107665Simp argv += optind; 148107665Simp 149107665Simp#define BACKWARD_COMPATIBILITY 150107665Simp#ifdef BACKWARD_COMPATIBILITY 151107665Simp if (*argv) { 152107665Simp interval = atoi(*argv); 153107665Simp if (*++argv) { 154107665Simp nlistf = *argv; 155246309Seadler if (*++argv) 156107665Simp memf = *argv; 157107665Simp } 158107665Simp } 159246270Seadler#endif 160107665Simp if (run_v4 != 0 && modfind("nfscommon") < 0) 161107665Simp errx(1, "experimental client/server not loaded"); 162107665Simp 163107665Simp if (run_v4 == 0 && (nlistf != NULL || memf != NULL)) { 164107665Simp deadkernel = 1; 165107665Simp 166246309Seadler if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, 167107665Simp errbuf)) == 0) { 168107665Simp errx(1, "kvm_openfiles: %s", errbuf); 169107665Simp } 170246270Seadler if (kvm_nlist(kd, nl) != 0) { 171107665Simp errx(1, "kvm_nlist: can't get names"); 172107665Simp } 173107665Simp } 174107665Simp 175107665Simp if (interval) { 176107665Simp if (run_v4 > 0) 177107665Simp exp_sidewaysintpr(interval, clientOnly, serverOnly); 178107665Simp else 179107665Simp sidewaysintpr(interval, clientOnly, serverOnly); 180107665Simp } else { 181107665Simp if (run_v4 > 0) 182107665Simp exp_intpr(clientOnly, serverOnly); 183107665Simp else 184107665Simp intpr(clientOnly, serverOnly); 185107665Simp } 186107665Simp exit(0); 187209583Simp} 188209583Simp 189209583Simp/* 190209583Simp * Read the nfs stats using sysctl(3) for live kernels, or kvm_read 191209583Simp * for dead ones. 192209583Simp */ 193209583Simpstatic void 194209583Simpreadstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero) 195209583Simp{ 196209583Simp union { 197209583Simp struct nfsstats client; 198209583Simp struct nfsrvstats server; 199209583Simp } zerostat; 200209583Simp size_t buflen; 201209583Simp 202209583Simp if (deadkernel) { 203209583Simp if (*stp != NULL && kvm_read(kd, (u_long)nl[N_NFSSTAT].n_value, 204209583Simp *stp, sizeof(struct nfsstats)) < 0) { 205209583Simp *stp = NULL; 206209583Simp } 207209583Simp if (*srvstp != NULL && kvm_read(kd, 208209583Simp (u_long)nl[N_NFSRVSTAT].n_value, *srvstp, 209209583Simp sizeof(struct nfsrvstats)) < 0) { 210209583Simp *srvstp = NULL; 211209583Simp } 212209583Simp } else { 213209583Simp if (zero) 214209583Simp bzero(&zerostat, sizeof(zerostat)); 215209583Simp buflen = sizeof(struct nfsstats); 216209583Simp if (*stp != NULL && sysctlbyname("vfs.nfs.nfsstats", *stp, 217209583Simp &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) { 218209583Simp if (errno != ENOENT) 219209583Simp err(1, "sysctl: vfs.nfs.nfsstats"); 220209583Simp *stp = NULL; 221209583Simp } 222209583Simp buflen = sizeof(struct nfsrvstats); 223209583Simp if (*srvstp != NULL && sysctlbyname("vfs.nfsrv.nfsrvstats", 224209583Simp *srvstp, &buflen, zero ? &zerostat : NULL, 225209583Simp zero ? buflen : 0) < 0) { 226209583Simp if (errno != ENOENT) 227209583Simp err(1, "sysctl: vfs.nfsrv.nfsrvstats"); 228209583Simp *srvstp = NULL; 229209583Simp } 230209583Simp } 231209583Simp} 232209583Simp 233209583Simp/* 234209583Simp * Print a description of the nfs stats. 235209583Simp */ 236209583Simpvoid 237209583Simpintpr(int clientOnly, int serverOnly) 238209583Simp{ 239209583Simp struct nfsstats nfsstats, *nfsstatsp; 240209583Simp struct nfsrvstats nfsrvstats, *nfsrvstatsp; 241107665Simp 242108014Simp /* 243107665Simp * Only read the stats we are going to display to avoid zeroing 244108783Simp * stats the user didn't request. 245113790Simp */ 246108783Simp if (clientOnly) 247209583Simp nfsstatsp = &nfsstats; 248107665Simp else 249107665Simp nfsstatsp = NULL; 250107665Simp if (serverOnly) 251108014Simp nfsrvstatsp = &nfsrvstats; 252244470Seadler else 253107665Simp nfsrvstatsp = NULL; 254108783Simp 255108783Simp readstats(&nfsstatsp, &nfsrvstatsp, zflag); 256154109Simp 257107665Simp if (clientOnly && !nfsstatsp) { 258107665Simp printf("Client not present!\n"); 259107665Simp clientOnly = 0; 260107665Simp } 261108014Simp if (clientOnly) { 262107665Simp printf("Client Info:\n"); 263107665Simp printf("Rpc Counts:\n"); 264107665Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 265108014Simp "Getattr", "Setattr", "Lookup", "Readlink", "Read", 266107665Simp "Write", "Create", "Remove"); 267210610Slulf printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 268108014Simp nfsstats.rpccnt[NFSPROC_GETATTR], 269108014Simp nfsstats.rpccnt[NFSPROC_SETATTR], 270113790Simp nfsstats.rpccnt[NFSPROC_LOOKUP], 271108783Simp nfsstats.rpccnt[NFSPROC_READLINK], 272108783Simp nfsstats.rpccnt[NFSPROC_READ], 273108783Simp nfsstats.rpccnt[NFSPROC_WRITE], 274108014Simp nfsstats.rpccnt[NFSPROC_CREATE], 275108014Simp nfsstats.rpccnt[NFSPROC_REMOVE]); 276107665Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 277107665Simp "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 278147874Simp "Readdir", "RdirPlus", "Access"); 279147874Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 280147874Simp nfsstats.rpccnt[NFSPROC_RENAME], 281147874Simp nfsstats.rpccnt[NFSPROC_LINK], 282151486Sbrooks nfsstats.rpccnt[NFSPROC_SYMLINK], 283147874Simp nfsstats.rpccnt[NFSPROC_MKDIR], 284147874Simp nfsstats.rpccnt[NFSPROC_RMDIR], 285147874Simp nfsstats.rpccnt[NFSPROC_READDIR], 286147874Simp nfsstats.rpccnt[NFSPROC_READDIRPLUS], 287147874Simp nfsstats.rpccnt[NFSPROC_ACCESS]); 288147874Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 289147874Simp "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit"); 290147874Simp printf("%9d %9d %9d %9d %9d\n", 291147874Simp nfsstats.rpccnt[NFSPROC_MKNOD], 292147874Simp nfsstats.rpccnt[NFSPROC_FSSTAT], 293147874Simp nfsstats.rpccnt[NFSPROC_FSINFO], 294147874Simp nfsstats.rpccnt[NFSPROC_PATHCONF], 295246270Seadler nfsstats.rpccnt[NFSPROC_COMMIT]); 296147874Simp printf("Rpc Info:\n"); 297147874Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 298147874Simp "TimedOut", "Invalid", "X Replies", "Retries", 299147874Simp "Requests"); 300147874Simp printf("%9d %9d %9d %9d %9d\n", 301147874Simp nfsstats.rpctimeouts, 302147874Simp nfsstats.rpcinvalid, 303147874Simp nfsstats.rpcunexpected, 304147874Simp nfsstats.rpcretries, 305147874Simp nfsstats.rpcrequests); 306147874Simp printf("Cache Info:\n"); 307147874Simp printf("%9.9s %9.9s %9.9s %9.9s", 308147874Simp "Attr Hits", "Misses", "Lkup Hits", "Misses"); 309150949Simp printf(" %9.9s %9.9s %9.9s %9.9s\n", 310147874Simp "BioR Hits", "Misses", "BioW Hits", "Misses"); 311147874Simp printf("%9d %9d %9d %9d", 312147874Simp nfsstats.attrcache_hits, nfsstats.attrcache_misses, 313147874Simp nfsstats.lookupcache_hits, nfsstats.lookupcache_misses); 314150949Simp printf(" %9d %9d %9d %9d\n", 315150949Simp nfsstats.biocache_reads-nfsstats.read_bios, 316150949Simp nfsstats.read_bios, 317150949Simp nfsstats.biocache_writes-nfsstats.write_bios, 318150949Simp nfsstats.write_bios); 319150949Simp printf("%9.9s %9.9s %9.9s %9.9s", 320150949Simp "BioRLHits", "Misses", "BioD Hits", "Misses"); 321151480Simp printf(" %9.9s %9.9s %9.9s %9.9s\n", "DirE Hits", "Misses", "Accs Hits", "Misses"); 322147874Simp printf("%9d %9d %9d %9d", 323147874Simp nfsstats.biocache_readlinks-nfsstats.readlink_bios, 324147874Simp nfsstats.readlink_bios, 325147874Simp nfsstats.biocache_readdirs-nfsstats.readdir_bios, 326147874Simp nfsstats.readdir_bios); 327147874Simp printf(" %9d %9d %9d %9d\n", 328147874Simp nfsstats.direofcache_hits, nfsstats.direofcache_misses, 329147874Simp nfsstats.accesscache_hits, nfsstats.accesscache_misses); 330147874Simp } 331147874Simp if (serverOnly && !nfsrvstatsp) { 332147874Simp printf("Server not present!\n"); 333147874Simp serverOnly = 0; 334147874Simp } 335147874Simp if (serverOnly) { 336147874Simp printf("\nServer Info:\n"); 337147874Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 338147874Simp "Getattr", "Setattr", "Lookup", "Readlink", "Read", 339147874Simp "Write", "Create", "Remove"); 340147874Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 341147874Simp nfsrvstats.srvrpccnt[NFSPROC_GETATTR], 342147874Simp nfsrvstats.srvrpccnt[NFSPROC_SETATTR], 343147874Simp nfsrvstats.srvrpccnt[NFSPROC_LOOKUP], 344147874Simp nfsrvstats.srvrpccnt[NFSPROC_READLINK], 345147874Simp nfsrvstats.srvrpccnt[NFSPROC_READ], 346147874Simp nfsrvstats.srvrpccnt[NFSPROC_WRITE], 347147874Simp nfsrvstats.srvrpccnt[NFSPROC_CREATE], 348147874Simp nfsrvstats.srvrpccnt[NFSPROC_REMOVE]); 349147874Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 350147874Simp "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 351107665Simp "Readdir", "RdirPlus", "Access"); 352107665Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 353107665Simp nfsrvstats.srvrpccnt[NFSPROC_RENAME], 354107665Simp nfsrvstats.srvrpccnt[NFSPROC_LINK], 355107665Simp nfsrvstats.srvrpccnt[NFSPROC_SYMLINK], 356107665Simp nfsrvstats.srvrpccnt[NFSPROC_MKDIR], 357107665Simp nfsrvstats.srvrpccnt[NFSPROC_RMDIR], 358107665Simp nfsrvstats.srvrpccnt[NFSPROC_READDIR], 359107665Simp nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS], 360107665Simp nfsrvstats.srvrpccnt[NFSPROC_ACCESS]); 361108783Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 362107665Simp "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit"); 363107665Simp printf("%9d %9d %9d %9d %9d\n", 364107665Simp nfsrvstats.srvrpccnt[NFSPROC_MKNOD], 365107665Simp nfsrvstats.srvrpccnt[NFSPROC_FSSTAT], 366107665Simp nfsrvstats.srvrpccnt[NFSPROC_FSINFO], 367107665Simp nfsrvstats.srvrpccnt[NFSPROC_PATHCONF], 368107665Simp nfsrvstats.srvrpccnt[NFSPROC_COMMIT]); 369107665Simp printf("Server Ret-Failed\n"); 370107665Simp printf("%17d\n", nfsrvstats.srvrpc_errs); 371107665Simp printf("Server Faults\n"); 372107665Simp printf("%13d\n", nfsrvstats.srv_errs); 373107665Simp printf("Server Cache Stats:\n"); 374113790Simp printf("%9.9s %9.9s %9.9s %9.9s\n", 375145218Simp "Inprog", "Idem", "Non-idem", "Misses"); 376107665Simp printf("%9d %9d %9d %9d\n", 377107665Simp nfsrvstats.srvcache_inproghits, 378107665Simp nfsrvstats.srvcache_idemdonehits, 379107665Simp nfsrvstats.srvcache_nonidemdonehits, 380107665Simp nfsrvstats.srvcache_misses); 381107665Simp printf("Server Write Gathering:\n"); 382107665Simp printf("%9.9s %9.9s %9.9s\n", 383108783Simp "WriteOps", "WriteRPC", "Opsaved"); 384108783Simp printf("%9d %9d %9d\n", 385108783Simp nfsrvstats.srvvop_writes, 386108783Simp nfsrvstats.srvrpccnt[NFSPROC_WRITE], 387121487Simp nfsrvstats.srvrpccnt[NFSPROC_WRITE] - 388107665Simp nfsrvstats.srvvop_writes); 389107665Simp } 390107665Simp} 391107665Simp 392107665Simpu_char signalled; /* set if alarm goes off "early" */ 393113790Simp 394186078Sphk/* 395107665Simp * Print a running summary of nfs statistics. 396107665Simp * Repeat display every interval seconds, showing statistics 397107665Simp * collected over that interval. Assumes that interval is non-zero. 398157746Smaxim * First line printed at top of screen is always cumulative. 399107665Simp */ 400107665Simpvoid 401107665Simpsidewaysintpr(u_int interval, int clientOnly, int serverOnly) 402107665Simp{ 403107665Simp struct nfsstats nfsstats, lastst, *nfsstatsp; 404107665Simp struct nfsrvstats nfsrvstats, lastsrvst, *nfsrvstatsp; 405107665Simp int hdrcnt = 1; 406107665Simp 407107665Simp nfsstatsp = &lastst; 408107665Simp nfsrvstatsp = &lastsrvst; 409107665Simp readstats(&nfsstatsp, &nfsrvstatsp, 0); 410107665Simp if (clientOnly && !nfsstatsp) { 411113790Simp printf("Client not present!\n"); 412186078Sphk clientOnly = 0; 413107665Simp } 414107665Simp if (serverOnly && !nfsrvstatsp) { 415107665Simp printf("Server not present!\n"); 416107665Simp serverOnly = 0; 417107665Simp } 418107665Simp sleep(interval); 419107665Simp 420107665Simp for (;;) { 421107665Simp nfsstatsp = &nfsstats; 422107665Simp nfsrvstatsp = &nfsrvstats; 423107665Simp readstats(&nfsstatsp, &nfsrvstatsp, 0); 424107665Simp 425215607Skevlo if (--hdrcnt == 0) { 426107665Simp printhdr(clientOnly, serverOnly); 427107665Simp if (clientOnly && serverOnly) 428108783Simp hdrcnt = 10; 429108783Simp else 430246309Seadler hdrcnt = 20; 431108783Simp } 432108783Simp if (clientOnly) { 433108783Simp printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 434108783Simp ((clientOnly && serverOnly) ? "Client:" : ""), 435108783Simp DELTA(attrcache_hits) + DELTA(attrcache_misses), 436107665Simp DELTA(lookupcache_hits) + DELTA(lookupcache_misses), 437108783Simp DELTA(biocache_readlinks), 438108783Simp DELTA(biocache_reads), 439244430Sdim DELTA(biocache_writes), 440108783Simp nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME], 441108783Simp DELTA(accesscache_hits) + DELTA(accesscache_misses), 442108783Simp DELTA(biocache_readdirs) 443107665Simp ); 444107665Simp if (widemode) { 445107665Simp printf(" %s %s %s %s %s %s", 446107665Simp sperc1(DELTA(attrcache_hits), 447152770Sjkoshy DELTA(attrcache_misses)), 448246270Seadler sperc1(DELTA(lookupcache_hits), 449107665Simp DELTA(lookupcache_misses)), 450108783Simp sperc2(DELTA(biocache_reads), 451108783Simp DELTA(read_bios)), 452108783Simp sperc2(DELTA(biocache_writes), 453121487Simp DELTA(write_bios)), 454107665Simp sperc1(DELTA(accesscache_hits), 455107665Simp DELTA(accesscache_misses)), 456107665Simp sperc2(DELTA(biocache_readdirs), 457155073Spjd DELTA(readdir_bios)) 458107665Simp ); 459155073Spjd } 460107665Simp printf("\n"); 461107665Simp lastst = nfsstats; 462107665Simp } 463155073Spjd if (serverOnly) { 464155073Spjd printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 465155073Spjd ((clientOnly && serverOnly) ? "Server:" : ""), 466155073Spjd nfsrvstats.srvrpccnt[NFSPROC_GETATTR]-lastsrvst.srvrpccnt[NFSPROC_GETATTR], 467155073Spjd nfsrvstats.srvrpccnt[NFSPROC_LOOKUP]-lastsrvst.srvrpccnt[NFSPROC_LOOKUP], 468155073Spjd nfsrvstats.srvrpccnt[NFSPROC_READLINK]-lastsrvst.srvrpccnt[NFSPROC_READLINK], 469107665Simp nfsrvstats.srvrpccnt[NFSPROC_READ]-lastsrvst.srvrpccnt[NFSPROC_READ], 470107665Simp nfsrvstats.srvrpccnt[NFSPROC_WRITE]-lastsrvst.srvrpccnt[NFSPROC_WRITE], 471107665Simp nfsrvstats.srvrpccnt[NFSPROC_RENAME]-lastsrvst.srvrpccnt[NFSPROC_RENAME], 472155073Spjd nfsrvstats.srvrpccnt[NFSPROC_ACCESS]-lastsrvst.srvrpccnt[NFSPROC_ACCESS], 473155073Spjd (nfsrvstats.srvrpccnt[NFSPROC_READDIR]-lastsrvst.srvrpccnt[NFSPROC_READDIR]) 474155073Spjd +(nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastsrvst.srvrpccnt[NFSPROC_READDIRPLUS])); 475155073Spjd printf("\n"); 476155073Spjd lastsrvst = nfsrvstats; 477155073Spjd } 478155073Spjd fflush(stdout); 479209583Simp sleep(interval); 480209583Simp } 481209583Simp /*NOTREACHED*/ 482209583Simp} 483209583Simp 484209583Simpvoid 485209583Simpprinthdr(int clientOnly, int serverOnly) 486155073Spjd{ 487155073Spjd printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s", 488155073Spjd ((serverOnly && clientOnly) ? " " : " "), 489155073Spjd "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename", 490155073Spjd "Access", "Rddir"); 491155073Spjd if (widemode && clientOnly) { 492155073Spjd printf(" Attr Lkup BioR BioW Accs BioD"); 493107665Simp } 494107665Simp printf("\n"); 495107665Simp fflush(stdout); 496107665Simp} 497107665Simp 498107665Simpvoid 499107665Simpusage(void) 500107665Simp{ 501107665Simp (void)fprintf(stderr, 502107665Simp "usage: nfsstat [-ceszW] [-M core] [-N system] [-w interval]\n"); 503107665Simp exit(1); 504107665Simp} 505107665Simp 506107665Simpstatic char SPBuf[64][8]; 507107665Simpstatic int SPIndex; 508107665Simp 509107665Simpchar * 510107665Simpsperc1(int hits, int misses) 511107665Simp{ 512107665Simp char *p = SPBuf[SPIndex]; 513107665Simp 514107665Simp if (hits + misses) { 515107665Simp sprintf(p, "%3d%%", 516107665Simp (int)(char)((quad_t)hits * 100 / (hits + misses))); 517107665Simp } else { 518107665Simp sprintf(p, " -"); 519107665Simp } 520121487Simp SPIndex = (SPIndex + 1) & 63; 521121487Simp return(p); 522121487Simp} 523121487Simp 524121487Simpchar * 525121487Simpsperc2(int ttl, int misses) 526121487Simp{ 527107665Simp char *p = SPBuf[SPIndex]; 528107665Simp 529107665Simp if (ttl) { 530107665Simp sprintf(p, "%3d%%", 531107665Simp (int)(char)((quad_t)(ttl - misses) * 100 / ttl)); 532107665Simp } else { 533107665Simp sprintf(p, " -"); 534107665Simp } 535107665Simp SPIndex = (SPIndex + 1) & 63; 536107665Simp return(p); 537107665Simp} 538107665Simp 539113790Simp/* 540108783Simp * Print a description of the nfs stats for the experimental client/server. 541107665Simp */ 542107665Simpvoid 543107665Simpexp_intpr(int clientOnly, int serverOnly) 544107665Simp{ 545107665Simp int nfssvc_flag; 546107665Simp 547107665Simp nfssvc_flag = NFSSVC_GETSTATS; 548113790Simp if (zflag != 0) { 549108783Simp if (clientOnly != 0) 550107665Simp nfssvc_flag |= NFSSVC_ZEROCLTSTATS; 551107665Simp if (serverOnly != 0) 552107665Simp nfssvc_flag |= NFSSVC_ZEROSRVSTATS; 553107665Simp } 554107665Simp if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0) 555107665Simp err(1, "Can't get stats"); 556107665Simp if (clientOnly != 0) { 557107665Simp if (printtitle) { 558107665Simp printf("Client Info:\n"); 559107665Simp printf("Rpc Counts:\n"); 560107665Simp printf( 561107665Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 562107665Simp , "Getattr", "Setattr", "Lookup", "Readlink", 563246270Seadler "Read", "Write", "Create", "Remove"); 564107665Simp } 565108783Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 566107665Simp ext_nfsstats.rpccnt[NFSPROC_GETATTR], 567107665Simp ext_nfsstats.rpccnt[NFSPROC_SETATTR], 568107665Simp ext_nfsstats.rpccnt[NFSPROC_LOOKUP], 569107665Simp ext_nfsstats.rpccnt[NFSPROC_READLINK], 570108783Simp ext_nfsstats.rpccnt[NFSPROC_READ], 571246309Seadler ext_nfsstats.rpccnt[NFSPROC_WRITE], 572108783Simp ext_nfsstats.rpccnt[NFSPROC_CREATE], 573108783Simp ext_nfsstats.rpccnt[NFSPROC_REMOVE]); 574108783Simp if (printtitle) 575108783Simp printf( 576108783Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 577108014Simp , "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 578114081Simp "Readdir", "RdirPlus", "Access"); 579107665Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 580108014Simp ext_nfsstats.rpccnt[NFSPROC_RENAME], 581210610Slulf ext_nfsstats.rpccnt[NFSPROC_LINK], 582108014Simp ext_nfsstats.rpccnt[NFSPROC_SYMLINK], 583108783Simp ext_nfsstats.rpccnt[NFSPROC_MKDIR], 584108014Simp ext_nfsstats.rpccnt[NFSPROC_RMDIR], 585108014Simp ext_nfsstats.rpccnt[NFSPROC_READDIR], 586114081Simp ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS], 587108014Simp ext_nfsstats.rpccnt[NFSPROC_ACCESS]); 588108014Simp if (printtitle) 589108014Simp printf( 590108014Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 591108783Simp , "Mknod", "Fsstat", "Fsinfo", "PathConf", 592108783Simp "Commit", "SetClId", "SetClIdCf", "Lock"); 593108014Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 594114081Simp ext_nfsstats.rpccnt[NFSPROC_MKNOD], 595108014Simp ext_nfsstats.rpccnt[NFSPROC_FSSTAT], 596114081Simp ext_nfsstats.rpccnt[NFSPROC_FSINFO], 597114081Simp ext_nfsstats.rpccnt[NFSPROC_PATHCONF], 598108014Simp ext_nfsstats.rpccnt[NFSPROC_COMMIT], 599108014Simp ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID], 600108014Simp ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM], 601108014Simp ext_nfsstats.rpccnt[NFSPROC_LOCK]); 602114081Simp if (printtitle) 603108014Simp printf("%9.9s %9.9s %9.9s %9.9s\n", 604108014Simp "LockT", "LockU", "Open", "OpenCfr"); 605108014Simp printf("%9d %9d %9d %9d\n", 606108014Simp ext_nfsstats.rpccnt[NFSPROC_LOCKT], 607108014Simp ext_nfsstats.rpccnt[NFSPROC_LOCKU], 608108014Simp ext_nfsstats.rpccnt[NFSPROC_OPEN], 609114081Simp ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]); 610114081Simp if (printtitle) 611108014Simp printf( 612108014Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 613108014Simp , "OpenOwner", "Opens", "LockOwner", 614108014Simp "Locks", "Delegs", "LocalOwn", 615114081Simp "LocalOpen", "LocalLOwn"); 616114081Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 617114084Simp ext_nfsstats.clopenowners, 618114081Simp ext_nfsstats.clopens, 619210610Slulf ext_nfsstats.cllockowners, 620107665Simp ext_nfsstats.cllocks, 621107665Simp ext_nfsstats.cldelegates, 622108014Simp ext_nfsstats.cllocalopenowners, 623108014Simp ext_nfsstats.cllocalopens, 624108014Simp ext_nfsstats.cllocallockowners); 625108014Simp if (printtitle) 626114081Simp printf("%9.9s\n", "LocalLock"); 627108014Simp printf("%9d\n", ext_nfsstats.cllocallocks); 628108014Simp if (printtitle) { 629108014Simp printf("Rpc Info:\n"); 630108014Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 631114081Simp "TimedOut", "Invalid", "X Replies", "Retries", 632108014Simp "Requests"); 633114081Simp } 634108014Simp printf("%9d %9d %9d %9d %9d\n", 635114081Simp ext_nfsstats.rpctimeouts, 636108014Simp ext_nfsstats.rpcinvalid, 637114081Simp ext_nfsstats.rpcunexpected, 638108014Simp ext_nfsstats.rpcretries, 639108014Simp ext_nfsstats.rpcrequests); 640108783Simp if (printtitle) { 641108783Simp printf("Cache Info:\n"); 642108783Simp printf("%9.9s %9.9s %9.9s %9.9s", 643108783Simp "Attr Hits", "Misses", "Lkup Hits", "Misses"); 644108783Simp printf(" %9.9s %9.9s %9.9s %9.9s\n", 645108783Simp "BioR Hits", "Misses", "BioW Hits", "Misses"); 646108783Simp } 647108783Simp printf("%9d %9d %9d %9d", 648108783Simp ext_nfsstats.attrcache_hits, 649108783Simp ext_nfsstats.attrcache_misses, 650108783Simp ext_nfsstats.lookupcache_hits, 651108783Simp ext_nfsstats.lookupcache_misses); 652108783Simp printf(" %9d %9d %9d %9d\n", 653108783Simp ext_nfsstats.biocache_reads - ext_nfsstats.read_bios, 654108783Simp ext_nfsstats.read_bios, 655108783Simp ext_nfsstats.biocache_writes - ext_nfsstats.write_bios, 656108783Simp ext_nfsstats.write_bios); 657108783Simp if (printtitle) { 658108783Simp printf("%9.9s %9.9s %9.9s %9.9s", 659108783Simp "BioRLHits", "Misses", "BioD Hits", "Misses"); 660108783Simp printf(" %9.9s %9.9s\n", "DirE Hits", "Misses"); 661108783Simp } 662108783Simp printf("%9d %9d %9d %9d", 663108783Simp ext_nfsstats.biocache_readlinks - 664108783Simp ext_nfsstats.readlink_bios, 665108783Simp ext_nfsstats.readlink_bios, 666108783Simp ext_nfsstats.biocache_readdirs - 667108783Simp ext_nfsstats.readdir_bios, 668108783Simp ext_nfsstats.readdir_bios); 669108783Simp printf(" %9d %9d\n", 670113785Simp ext_nfsstats.direofcache_hits, 671113785Simp ext_nfsstats.direofcache_misses); 672108783Simp } 673108783Simp if (serverOnly != 0) { 674108783Simp if (printtitle) { 675108783Simp printf("\nServer Info:\n"); 676108783Simp printf( 677108783Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 678108783Simp , "Getattr", "Setattr", "Lookup", "Readlink", 679108783Simp "Read", "Write", "Create", "Remove"); 680108783Simp } 681108783Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 682108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR], 683108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR], 684108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP], 685108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_READLINK], 686108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_READ], 687108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 688108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE], 689108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]); 690108783Simp if (printtitle) 691108783Simp printf( 692108783Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 693108783Simp , "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 694108783Simp "Readdir", "RdirPlus", "Access"); 695108783Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 696151486Sbrooks ext_nfsstats.srvrpccnt[NFSV4OP_RENAME], 697108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_LINK], 698108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK], 699108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR], 700108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR], 701121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_READDIR], 702121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS], 703121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]); 704121487Simp if (printtitle) 705108783Simp printf( 706108783Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 707108783Simp , "Mknod", "Fsstat", "Fsinfo", "PathConf", 708108783Simp "Commit", "LookupP", "SetClId", "SetClIdCf"); 709108783Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 710108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD], 711108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT], 712108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO], 713108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF], 714108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT], 715108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP], 716108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID], 717108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]); 718113790Simp if (printtitle) 719108783Simp printf( 720246270Seadler "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 721108783Simp , "Open", "OpenAttr", "OpenDwnGr", "OpenCfrm", 722108783Simp "DelePurge", "DeleRet", "GetFH", "Lock"); 723108783Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 724108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_OPEN], 725108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR], 726108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE], 727108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM], 728108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE], 729107665Simp ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN], 730107665Simp ext_nfsstats.srvrpccnt[NFSV4OP_GETFH], 731108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_LOCK]); 732107665Simp if (printtitle) 733107665Simp printf( 734107665Simp "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 735107665Simp , "LockT", "LockU", "Close", "Verify", "NVerify", 736108783Simp "PutFH", "PutPubFH", "PutRootFH"); 737113790Simp printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 738108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT], 739107665Simp ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU], 740108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE], 741108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY], 742108783Simp ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY], 743121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH], 744121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH], 745121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH]); 746121487Simp if (printtitle) 747121487Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 748145218Simp "Renew", "RestoreFH", "SaveFH", "Secinfo", 749145218Simp "RelLckOwn", "V4Create"); 750145218Simp printf("%9d %9d %9d %9d %9d %9d\n", 751145218Simp ext_nfsstats.srvrpccnt[NFSV4OP_RENEW], 752145218Simp ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH], 753213646Simp ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH], 754213646Simp ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO], 755121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN], 756121487Simp ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]); 757121487Simp if (printtitle) { 758213646Simp printf("Server:\n"); 759213646Simp printf("%9.9s %9.9s %9.9s\n", 760121487Simp "Retfailed", "Faults", "Clients"); 761121487Simp } 762121487Simp printf("%9d %9d %9d\n", 763121487Simp ext_nfsstats.srv_errs, ext_nfsstats.srvrpc_errs, 764121487Simp ext_nfsstats.srvclients); 765108783Simp if (printtitle) 766108783Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s \n", 767108783Simp "OpenOwner", "Opens", "LockOwner", 768108783Simp "Locks", "Delegs"); 769108783Simp printf("%9d %9d %9d %9d %9d \n", 770213646Simp ext_nfsstats.srvopenowners, 771213646Simp ext_nfsstats.srvopens, 772113785Simp ext_nfsstats.srvlockowners, 773113785Simp ext_nfsstats.srvlocks, 774113785Simp ext_nfsstats.srvdelegates); 775213646Simp if (printtitle) { 776213646Simp printf("Server Cache Stats:\n"); 777113785Simp printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 778113785Simp "Inprog", "Idem", "Non-idem", "Misses", 779121487Simp "CacheSize", "TCPPeak"); 780108783Simp } 781113785Simp printf("%9d %9d %9d %9d %9d %9d\n", 782108783Simp ext_nfsstats.srvcache_inproghits, 783108783Simp ext_nfsstats.srvcache_idemdonehits, 784107665Simp ext_nfsstats.srvcache_nonidemdonehits, 785107665Simp ext_nfsstats.srvcache_misses, 786131397Simp ext_nfsstats.srvcache_size, 787131397Simp ext_nfsstats.srvcache_tcppeak); 788131397Simp } 789131397Simp} 790131397Simp 791131397Simp/* 792131397Simp * Print a running summary of nfs statistics for the experimental client and/or 793131397Simp * server. 794131397Simp * Repeat display every interval seconds, showing statistics 795131397Simp * collected over that interval. Assumes that interval is non-zero. 796131397Simp * First line printed at top of screen is always cumulative. 797131397Simp */ 798131397Simpvoid 799147973Smarcusexp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly) 800147973Smarcus{ 801236540Sdim struct ext_nfsstats nfsstats, lastst, *ext_nfsstatsp; 802131397Simp int hdrcnt = 1; 803131397Simp 804147972Smarcus ext_nfsstatsp = &lastst; 805147973Smarcus if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) 806131397Simp err(1, "Can't get stats"); 807131397Simp sleep(interval); 808131397Simp 809247576Sian for (;;) { 810247576Sian ext_nfsstatsp = &nfsstats; 811131397Simp if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) 812131397Simp err(1, "Can't get stats"); 813131397Simp 814131397Simp if (--hdrcnt == 0) { 815131397Simp printhdr(clientOnly, serverOnly); 816247576Sian if (clientOnly && serverOnly) 817131397Simp hdrcnt = 10; 818247576Sian else 819247576Sian hdrcnt = 20; 820247576Sian } 821247576Sian if (clientOnly) { 822247576Sian printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 823247576Sian ((clientOnly && serverOnly) ? "Client:" : ""), 824247576Sian DELTA(attrcache_hits) + DELTA(attrcache_misses), 825247576Sian DELTA(lookupcache_hits) + DELTA(lookupcache_misses), 826247576Sian DELTA(biocache_readlinks), 827247576Sian DELTA(biocache_reads), 828131397Simp DELTA(biocache_writes), 829247576Sian nfsstats.rpccnt[NFSPROC_RENAME] - 830247576Sian lastst.rpccnt[NFSPROC_RENAME], 831247576Sian DELTA(accesscache_hits) + DELTA(accesscache_misses), 832131397Simp DELTA(biocache_readdirs) 833247576Sian ); 834131397Simp if (widemode) { 835247576Sian printf(" %s %s %s %s %s %s", 836247576Sian sperc1(DELTA(attrcache_hits), 837247576Sian DELTA(attrcache_misses)), 838247576Sian sperc1(DELTA(lookupcache_hits), 839247576Sian DELTA(lookupcache_misses)), 840247576Sian sperc2(DELTA(biocache_reads), 841247576Sian DELTA(read_bios)), 842247576Sian sperc2(DELTA(biocache_writes), 843247576Sian DELTA(write_bios)), 844247576Sian sperc1(DELTA(accesscache_hits), 845247576Sian DELTA(accesscache_misses)), 846247576Sian sperc2(DELTA(biocache_readdirs), 847247576Sian DELTA(readdir_bios)) 848247576Sian ); 849247576Sian } 850247576Sian printf("\n"); 851247576Sian lastst = nfsstats; 852247576Sian } 853247576Sian if (serverOnly) { 854247576Sian printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 855247576Sian ((clientOnly && serverOnly) ? "Server:" : ""), 856247576Sian nfsstats.srvrpccnt[NFSPROC_GETATTR] - 857247576Sian lastst.srvrpccnt[NFSPROC_GETATTR], 858247576Sian nfsstats.srvrpccnt[NFSPROC_LOOKUP] - 859247576Sian lastst.srvrpccnt[NFSPROC_LOOKUP], 860247576Sian nfsstats.srvrpccnt[NFSPROC_READLINK] - 861131397Simp lastst.srvrpccnt[NFSPROC_READLINK], 862131397Simp nfsstats.srvrpccnt[NFSPROC_READ] - 863131397Simp lastst.srvrpccnt[NFSPROC_READ], 864131397Simp nfsstats.srvrpccnt[NFSPROC_WRITE] - 865131397Simp lastst.srvrpccnt[NFSPROC_WRITE], 866131397Simp nfsstats.srvrpccnt[NFSPROC_RENAME] - 867131397Simp lastst.srvrpccnt[NFSPROC_RENAME], 868247576Sian nfsstats.srvrpccnt[NFSPROC_ACCESS] - 869247576Sian lastst.srvrpccnt[NFSPROC_ACCESS], 870247576Sian (nfsstats.srvrpccnt[NFSPROC_READDIR] - 871247576Sian lastst.srvrpccnt[NFSPROC_READDIR]) + 872247576Sian (nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] - 873247576Sian lastst.srvrpccnt[NFSPROC_READDIRPLUS])); 874131397Simp printf("\n"); 875247576Sian lastst = nfsstats; 876247576Sian } 877131397Simp fflush(stdout); 878247576Sian sleep(interval); 879247576Sian } 880131397Simp /*NOTREACHED*/ 881131397Simp} 882107665Simp 883107665Simp