1 /* 2 * Copyright (c) 1983, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Rick Macklem at The University of Guelph. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 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 * 4. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 #ifndef lint 34 static const char copyright[] = 35 "@(#) Copyright (c) 1983, 1989, 1993\n\ 36 The Regents of the University of California. All rights reserved.\n"; 37 #endif /* not lint */ 38 39 #ifndef lint 40 #if 0 41 static char sccsid[] = "@(#)nfsstat.c 8.2 (Berkeley) 3/31/95"; 42 #endif 43 static const char rcsid[] = 44 "$FreeBSD$"; 45 #endif /* not lint */ 46 47 #include <sys/param.h> 48 #include <sys/module.h> 49 #include <sys/mount.h> 50 #include <sys/time.h> 51 #include <sys/sysctl.h> 52 #include <nfs/nfsproto.h> 53 #include <nfsclient/nfs.h> 54 #include <nfsserver/nfs.h> 55 #include <nfs/nfssvc.h> 56 57 #include <fs/nfs/nfsport.h> 58 59 #include <signal.h> 60 #include <fcntl.h> 61 #include <ctype.h> 62 #include <errno.h> 63 #include <kvm.h> 64 #include <limits.h> 65 #include <nlist.h> 66 #include <unistd.h> 67 #include <stdio.h> 68 #include <stdlib.h> 69 #include <string.h> 70 #include <paths.h> 71 #include <err.h> 72 73 struct nlist nl[] = { 74 #define N_NFSSTAT 0 75 { .n_name = "nfsstats" }, 76 #define N_NFSRVSTAT 1 77 { .n_name = "nfsrvstats" }, 78 { .n_name = NULL }, 79 }; 80 kvm_t *kd; 81 82 static int deadkernel = 0; 83 static int widemode = 0; 84 static int zflag = 0; 85 static int run_v4 = 1; 86 static int printtitle = 1; 87 static struct ext_nfsstats ext_nfsstats; 88 static int extra_output = 0; 89 90 void intpr(int, int); 91 void printhdr(int, int); 92 void sidewaysintpr(u_int, int, int); 93 void usage(void); 94 char *sperc1(int, int); 95 char *sperc2(int, int); 96 void exp_intpr(int, int); 97 void exp_sidewaysintpr(u_int, int, int); 98 99 #define DELTA(field) (nfsstats.field - lastst.field) 100 101 int 102 main(int argc, char **argv) 103 { 104 u_int interval; 105 int clientOnly = -1; 106 int serverOnly = -1; 107 int ch; 108 char *memf, *nlistf; 109 char errbuf[_POSIX2_LINE_MAX]; 110 int mntlen, i; 111 char buf[1024]; 112 struct statfs *mntbuf; 113 struct nfscl_dumpmntopts dumpmntopts; 114 115 interval = 0; 116 memf = nlistf = NULL; 117 while ((ch = getopt(argc, argv, "cesWM:mN:ow:z")) != -1) 118 switch(ch) { 119 case 'M': 120 memf = optarg; 121 break; 122 case 'm': 123 /* Display mount options for NFS mount points. */ 124 mntlen = getmntinfo(&mntbuf, MNT_NOWAIT); 125 for (i = 0; i < mntlen; i++) { 126 if (strcmp(mntbuf->f_fstypename, "nfs") == 0) { 127 dumpmntopts.ndmnt_fname = 128 mntbuf->f_mntonname; 129 dumpmntopts.ndmnt_buf = buf; 130 dumpmntopts.ndmnt_blen = sizeof(buf); 131 if (nfssvc(NFSSVC_DUMPMNTOPTS, 132 &dumpmntopts) >= 0) 133 printf("%s on %s\n%s\n", 134 mntbuf->f_mntfromname, 135 mntbuf->f_mntonname, buf); 136 else if (errno == EPERM) 137 errx(1, "Only priviledged users" 138 " can use the -m option"); 139 } 140 mntbuf++; 141 } 142 exit(0); 143 case 'N': 144 nlistf = optarg; 145 break; 146 case 'W': 147 widemode = 1; 148 break; 149 case 'w': 150 interval = atoi(optarg); 151 break; 152 case 'c': 153 clientOnly = 1; 154 if (serverOnly < 0) 155 serverOnly = 0; 156 break; 157 case 's': 158 serverOnly = 1; 159 if (clientOnly < 0) 160 clientOnly = 0; 161 break; 162 case 'z': 163 zflag = 1; 164 break; 165 case 'o': 166 if (extra_output != 0) 167 err(1, "-o incompatible with -e"); 168 run_v4 = 0; 169 break; 170 case 'e': 171 if (run_v4 == 0) 172 err(1, "-e incompatible with -o"); 173 extra_output = 1; 174 break; 175 case '?': 176 default: 177 usage(); 178 } 179 argc -= optind; 180 argv += optind; 181 182 #define BACKWARD_COMPATIBILITY 183 #ifdef BACKWARD_COMPATIBILITY 184 if (*argv) { 185 interval = atoi(*argv); 186 if (*++argv) { 187 nlistf = *argv; 188 if (*++argv) 189 memf = *argv; 190 } 191 } 192 #endif 193 if (run_v4 != 0 && modfind("nfscommon") < 0) 194 errx(1, "new client/server not loaded"); 195 196 if (run_v4 == 0 && (nlistf != NULL || memf != NULL)) { 197 deadkernel = 1; 198 199 if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, 200 errbuf)) == 0) { 201 errx(1, "kvm_openfiles: %s", errbuf); 202 } 203 if (kvm_nlist(kd, nl) != 0) { 204 errx(1, "kvm_nlist: can't get names"); 205 } 206 } 207 208 if (interval) { 209 if (run_v4 > 0) 210 exp_sidewaysintpr(interval, clientOnly, serverOnly); 211 else 212 sidewaysintpr(interval, clientOnly, serverOnly); 213 } else { 214 if (extra_output != 0) 215 exp_intpr(clientOnly, serverOnly); 216 else 217 intpr(clientOnly, serverOnly); 218 } 219 exit(0); 220 } 221 222 /* 223 * Read the nfs stats using sysctl(3) for live kernels, or kvm_read 224 * for dead ones. 225 */ 226 static void 227 readstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero) 228 { 229 union { 230 struct nfsstats client; 231 struct nfsrvstats server; 232 } zerostat; 233 size_t buflen; 234 235 if (deadkernel) { 236 if (*stp != NULL && kvm_read(kd, (u_long)nl[N_NFSSTAT].n_value, 237 *stp, sizeof(struct nfsstats)) < 0) { 238 *stp = NULL; 239 } 240 if (*srvstp != NULL && kvm_read(kd, 241 (u_long)nl[N_NFSRVSTAT].n_value, *srvstp, 242 sizeof(struct nfsrvstats)) < 0) { 243 *srvstp = NULL; 244 } 245 } else { 246 if (zero) 247 bzero(&zerostat, sizeof(zerostat)); 248 buflen = sizeof(struct nfsstats); 249 if (*stp != NULL && sysctlbyname("vfs.oldnfs.nfsstats", *stp, 250 &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) { 251 if (errno != ENOENT) 252 err(1, "sysctl: vfs.oldnfs.nfsstats"); 253 *stp = NULL; 254 } 255 buflen = sizeof(struct nfsrvstats); 256 if (*srvstp != NULL && sysctlbyname("vfs.nfsrv.nfsrvstats", 257 *srvstp, &buflen, zero ? &zerostat : NULL, 258 zero ? buflen : 0) < 0) { 259 if (errno != ENOENT) 260 err(1, "sysctl: vfs.nfsrv.nfsrvstats"); 261 *srvstp = NULL; 262 } 263 } 264 } 265 266 /* 267 * Print a description of the nfs stats. 268 */ 269 void 270 intpr(int clientOnly, int serverOnly) 271 { 272 struct nfsstats nfsstats, *nfsstatsp; 273 struct nfsrvstats nfsrvstats, *nfsrvstatsp; 274 int nfssvc_flag; 275 276 if (run_v4 == 0) { 277 /* 278 * Only read the stats we are going to display to avoid zeroing 279 * stats the user didn't request. 280 */ 281 if (clientOnly) 282 nfsstatsp = &nfsstats; 283 else 284 nfsstatsp = NULL; 285 if (serverOnly) 286 nfsrvstatsp = &nfsrvstats; 287 else 288 nfsrvstatsp = NULL; 289 290 readstats(&nfsstatsp, &nfsrvstatsp, zflag); 291 292 if (clientOnly && !nfsstatsp) { 293 printf("Client not present!\n"); 294 clientOnly = 0; 295 } 296 } else { 297 nfssvc_flag = NFSSVC_GETSTATS; 298 if (zflag != 0) { 299 if (clientOnly != 0) 300 nfssvc_flag |= NFSSVC_ZEROCLTSTATS; 301 if (serverOnly != 0) 302 nfssvc_flag |= NFSSVC_ZEROSRVSTATS; 303 } 304 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0) 305 err(1, "Can't get stats"); 306 } 307 if (clientOnly) { 308 printf("Client Info:\n"); 309 printf("Rpc Counts:\n"); 310 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 311 "Getattr", "Setattr", "Lookup", "Readlink", "Read", 312 "Write", "Create", "Remove"); 313 if (run_v4 == 0) 314 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 315 nfsstats.rpccnt[NFSPROC_GETATTR], 316 nfsstats.rpccnt[NFSPROC_SETATTR], 317 nfsstats.rpccnt[NFSPROC_LOOKUP], 318 nfsstats.rpccnt[NFSPROC_READLINK], 319 nfsstats.rpccnt[NFSPROC_READ], 320 nfsstats.rpccnt[NFSPROC_WRITE], 321 nfsstats.rpccnt[NFSPROC_CREATE], 322 nfsstats.rpccnt[NFSPROC_REMOVE]); 323 else 324 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 325 ext_nfsstats.rpccnt[NFSPROC_GETATTR], 326 ext_nfsstats.rpccnt[NFSPROC_SETATTR], 327 ext_nfsstats.rpccnt[NFSPROC_LOOKUP], 328 ext_nfsstats.rpccnt[NFSPROC_READLINK], 329 ext_nfsstats.rpccnt[NFSPROC_READ], 330 ext_nfsstats.rpccnt[NFSPROC_WRITE], 331 ext_nfsstats.rpccnt[NFSPROC_CREATE], 332 ext_nfsstats.rpccnt[NFSPROC_REMOVE]); 333 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 334 "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 335 "Readdir", "RdirPlus", "Access"); 336 if (run_v4 == 0) 337 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 338 nfsstats.rpccnt[NFSPROC_RENAME], 339 nfsstats.rpccnt[NFSPROC_LINK], 340 nfsstats.rpccnt[NFSPROC_SYMLINK], 341 nfsstats.rpccnt[NFSPROC_MKDIR], 342 nfsstats.rpccnt[NFSPROC_RMDIR], 343 nfsstats.rpccnt[NFSPROC_READDIR], 344 nfsstats.rpccnt[NFSPROC_READDIRPLUS], 345 nfsstats.rpccnt[NFSPROC_ACCESS]); 346 else 347 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 348 ext_nfsstats.rpccnt[NFSPROC_RENAME], 349 ext_nfsstats.rpccnt[NFSPROC_LINK], 350 ext_nfsstats.rpccnt[NFSPROC_SYMLINK], 351 ext_nfsstats.rpccnt[NFSPROC_MKDIR], 352 ext_nfsstats.rpccnt[NFSPROC_RMDIR], 353 ext_nfsstats.rpccnt[NFSPROC_READDIR], 354 ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS], 355 ext_nfsstats.rpccnt[NFSPROC_ACCESS]); 356 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 357 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit"); 358 if (run_v4 == 0) 359 printf("%9d %9d %9d %9d %9d\n", 360 nfsstats.rpccnt[NFSPROC_MKNOD], 361 nfsstats.rpccnt[NFSPROC_FSSTAT], 362 nfsstats.rpccnt[NFSPROC_FSINFO], 363 nfsstats.rpccnt[NFSPROC_PATHCONF], 364 nfsstats.rpccnt[NFSPROC_COMMIT]); 365 else 366 printf("%9d %9d %9d %9d %9d\n", 367 ext_nfsstats.rpccnt[NFSPROC_MKNOD], 368 ext_nfsstats.rpccnt[NFSPROC_FSSTAT], 369 ext_nfsstats.rpccnt[NFSPROC_FSINFO], 370 ext_nfsstats.rpccnt[NFSPROC_PATHCONF], 371 ext_nfsstats.rpccnt[NFSPROC_COMMIT]); 372 printf("Rpc Info:\n"); 373 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 374 "TimedOut", "Invalid", "X Replies", "Retries", 375 "Requests"); 376 if (run_v4 == 0) 377 printf("%9d %9d %9d %9d %9d\n", 378 nfsstats.rpctimeouts, 379 nfsstats.rpcinvalid, 380 nfsstats.rpcunexpected, 381 nfsstats.rpcretries, 382 nfsstats.rpcrequests); 383 else 384 printf("%9d %9d %9d %9d %9d\n", 385 ext_nfsstats.rpctimeouts, 386 ext_nfsstats.rpcinvalid, 387 ext_nfsstats.rpcunexpected, 388 ext_nfsstats.rpcretries, 389 ext_nfsstats.rpcrequests); 390 printf("Cache Info:\n"); 391 printf("%9.9s %9.9s %9.9s %9.9s", 392 "Attr Hits", "Misses", "Lkup Hits", "Misses"); 393 printf(" %9.9s %9.9s %9.9s %9.9s\n", 394 "BioR Hits", "Misses", "BioW Hits", "Misses"); 395 if (run_v4 == 0) { 396 printf("%9d %9d %9d %9d", 397 nfsstats.attrcache_hits, 398 nfsstats.attrcache_misses, 399 nfsstats.lookupcache_hits, 400 nfsstats.lookupcache_misses); 401 printf(" %9d %9d %9d %9d\n", 402 nfsstats.biocache_reads-nfsstats.read_bios, 403 nfsstats.read_bios, 404 nfsstats.biocache_writes-nfsstats.write_bios, 405 nfsstats.write_bios); 406 } else { 407 printf("%9d %9d %9d %9d", 408 ext_nfsstats.attrcache_hits, 409 ext_nfsstats.attrcache_misses, 410 ext_nfsstats.lookupcache_hits, 411 ext_nfsstats.lookupcache_misses); 412 printf(" %9d %9d %9d %9d\n", 413 ext_nfsstats.biocache_reads - 414 ext_nfsstats.read_bios, 415 ext_nfsstats.read_bios, 416 ext_nfsstats.biocache_writes - 417 ext_nfsstats.write_bios, 418 ext_nfsstats.write_bios); 419 } 420 printf("%9.9s %9.9s %9.9s %9.9s", 421 "BioRLHits", "Misses", "BioD Hits", "Misses"); 422 printf(" %9.9s %9.9s %9.9s %9.9s\n", "DirE Hits", "Misses", "Accs Hits", "Misses"); 423 if (run_v4 == 0) { 424 printf("%9d %9d %9d %9d", 425 nfsstats.biocache_readlinks - 426 nfsstats.readlink_bios, 427 nfsstats.readlink_bios, 428 nfsstats.biocache_readdirs - 429 nfsstats.readdir_bios, 430 nfsstats.readdir_bios); 431 printf(" %9d %9d %9d %9d\n", 432 nfsstats.direofcache_hits, 433 nfsstats.direofcache_misses, 434 nfsstats.accesscache_hits, 435 nfsstats.accesscache_misses); 436 } else { 437 printf("%9d %9d %9d %9d", 438 ext_nfsstats.biocache_readlinks - 439 ext_nfsstats.readlink_bios, 440 ext_nfsstats.readlink_bios, 441 ext_nfsstats.biocache_readdirs - 442 ext_nfsstats.readdir_bios, 443 ext_nfsstats.readdir_bios); 444 printf(" %9d %9d %9d %9d\n", 445 ext_nfsstats.direofcache_hits, 446 ext_nfsstats.direofcache_misses, 447 ext_nfsstats.accesscache_hits, 448 ext_nfsstats.accesscache_misses); 449 } 450 } 451 if (run_v4 == 0 && serverOnly && !nfsrvstatsp) { 452 printf("Server not present!\n"); 453 serverOnly = 0; 454 } 455 if (serverOnly) { 456 printf("\nServer Info:\n"); 457 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 458 "Getattr", "Setattr", "Lookup", "Readlink", "Read", 459 "Write", "Create", "Remove"); 460 if (run_v4 == 0) 461 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 462 nfsrvstats.srvrpccnt[NFSPROC_GETATTR], 463 nfsrvstats.srvrpccnt[NFSPROC_SETATTR], 464 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP], 465 nfsrvstats.srvrpccnt[NFSPROC_READLINK], 466 nfsrvstats.srvrpccnt[NFSPROC_READ], 467 nfsrvstats.srvrpccnt[NFSPROC_WRITE], 468 nfsrvstats.srvrpccnt[NFSPROC_CREATE], 469 nfsrvstats.srvrpccnt[NFSPROC_REMOVE]); 470 else 471 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 472 ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR], 473 ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR], 474 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP], 475 ext_nfsstats.srvrpccnt[NFSV4OP_READLINK], 476 ext_nfsstats.srvrpccnt[NFSV4OP_READ], 477 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 478 ext_nfsstats.srvrpccnt[NFSV4OP_CREATE], 479 ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]); 480 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 481 "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 482 "Readdir", "RdirPlus", "Access"); 483 if (run_v4 == 0) 484 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 485 nfsrvstats.srvrpccnt[NFSPROC_RENAME], 486 nfsrvstats.srvrpccnt[NFSPROC_LINK], 487 nfsrvstats.srvrpccnt[NFSPROC_SYMLINK], 488 nfsrvstats.srvrpccnt[NFSPROC_MKDIR], 489 nfsrvstats.srvrpccnt[NFSPROC_RMDIR], 490 nfsrvstats.srvrpccnt[NFSPROC_READDIR], 491 nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS], 492 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]); 493 else 494 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 495 ext_nfsstats.srvrpccnt[NFSV4OP_RENAME], 496 ext_nfsstats.srvrpccnt[NFSV4OP_LINK], 497 ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK], 498 ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR], 499 ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR], 500 ext_nfsstats.srvrpccnt[NFSV4OP_READDIR], 501 ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS], 502 ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]); 503 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 504 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit"); 505 if (run_v4 == 0) 506 printf("%9d %9d %9d %9d %9d\n", 507 nfsrvstats.srvrpccnt[NFSPROC_MKNOD], 508 nfsrvstats.srvrpccnt[NFSPROC_FSSTAT], 509 nfsrvstats.srvrpccnt[NFSPROC_FSINFO], 510 nfsrvstats.srvrpccnt[NFSPROC_PATHCONF], 511 nfsrvstats.srvrpccnt[NFSPROC_COMMIT]); 512 else 513 printf("%9d %9d %9d %9d %9d\n", 514 ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD], 515 ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT], 516 ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO], 517 ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF], 518 ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT]); 519 printf("Server Ret-Failed\n"); 520 if (run_v4 == 0) 521 printf("%17d\n", nfsrvstats.srvrpc_errs); 522 else 523 printf("%17d\n", ext_nfsstats.srvrpc_errs); 524 printf("Server Faults\n"); 525 if (run_v4 == 0) 526 printf("%13d\n", nfsrvstats.srv_errs); 527 else 528 printf("%13d\n", ext_nfsstats.srv_errs); 529 printf("Server Cache Stats:\n"); 530 printf("%9.9s %9.9s %9.9s %9.9s\n", 531 "Inprog", "Idem", "Non-idem", "Misses"); 532 if (run_v4 == 0) 533 printf("%9d %9d %9d %9d\n", 534 nfsrvstats.srvcache_inproghits, 535 nfsrvstats.srvcache_idemdonehits, 536 nfsrvstats.srvcache_nonidemdonehits, 537 nfsrvstats.srvcache_misses); 538 else 539 printf("%9d %9d %9d %9d\n", 540 ext_nfsstats.srvcache_inproghits, 541 ext_nfsstats.srvcache_idemdonehits, 542 ext_nfsstats.srvcache_nonidemdonehits, 543 ext_nfsstats.srvcache_misses); 544 printf("Server Write Gathering:\n"); 545 printf("%9.9s %9.9s %9.9s\n", 546 "WriteOps", "WriteRPC", "Opsaved"); 547 if (run_v4 == 0) 548 printf("%9d %9d %9d\n", 549 nfsrvstats.srvvop_writes, 550 nfsrvstats.srvrpccnt[NFSPROC_WRITE], 551 nfsrvstats.srvrpccnt[NFSPROC_WRITE] - 552 nfsrvstats.srvvop_writes); 553 else 554 /* 555 * The new client doesn't do write gathering. It was 556 * only useful for NFSv2. 557 */ 558 printf("%9d %9d %9d\n", 559 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 560 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 0); 561 } 562 } 563 564 u_char signalled; /* set if alarm goes off "early" */ 565 566 /* 567 * Print a running summary of nfs statistics. 568 * Repeat display every interval seconds, showing statistics 569 * collected over that interval. Assumes that interval is non-zero. 570 * First line printed at top of screen is always cumulative. 571 */ 572 void 573 sidewaysintpr(u_int interval, int clientOnly, int serverOnly) 574 { 575 struct nfsstats nfsstats, lastst, *nfsstatsp; 576 struct nfsrvstats nfsrvstats, lastsrvst, *nfsrvstatsp; 577 int hdrcnt = 1; 578 579 nfsstatsp = &lastst; 580 nfsrvstatsp = &lastsrvst; 581 readstats(&nfsstatsp, &nfsrvstatsp, 0); 582 if (clientOnly && !nfsstatsp) { 583 printf("Client not present!\n"); 584 clientOnly = 0; 585 } 586 if (serverOnly && !nfsrvstatsp) { 587 printf("Server not present!\n"); 588 serverOnly = 0; 589 } 590 sleep(interval); 591 592 for (;;) { 593 nfsstatsp = &nfsstats; 594 nfsrvstatsp = &nfsrvstats; 595 readstats(&nfsstatsp, &nfsrvstatsp, 0); 596 597 if (--hdrcnt == 0) { 598 printhdr(clientOnly, serverOnly); 599 if (clientOnly && serverOnly) 600 hdrcnt = 10; 601 else 602 hdrcnt = 20; 603 } 604 if (clientOnly) { 605 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 606 ((clientOnly && serverOnly) ? "Client:" : ""), 607 DELTA(attrcache_hits) + DELTA(attrcache_misses), 608 DELTA(lookupcache_hits) + DELTA(lookupcache_misses), 609 DELTA(biocache_readlinks), 610 DELTA(biocache_reads), 611 DELTA(biocache_writes), 612 nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME], 613 DELTA(accesscache_hits) + DELTA(accesscache_misses), 614 DELTA(biocache_readdirs) 615 ); 616 if (widemode) { 617 printf(" %s %s %s %s %s %s", 618 sperc1(DELTA(attrcache_hits), 619 DELTA(attrcache_misses)), 620 sperc1(DELTA(lookupcache_hits), 621 DELTA(lookupcache_misses)), 622 sperc2(DELTA(biocache_reads), 623 DELTA(read_bios)), 624 sperc2(DELTA(biocache_writes), 625 DELTA(write_bios)), 626 sperc1(DELTA(accesscache_hits), 627 DELTA(accesscache_misses)), 628 sperc2(DELTA(biocache_readdirs), 629 DELTA(readdir_bios)) 630 ); 631 } 632 printf("\n"); 633 lastst = nfsstats; 634 } 635 if (serverOnly) { 636 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 637 ((clientOnly && serverOnly) ? "Server:" : ""), 638 nfsrvstats.srvrpccnt[NFSPROC_GETATTR]-lastsrvst.srvrpccnt[NFSPROC_GETATTR], 639 nfsrvstats.srvrpccnt[NFSPROC_LOOKUP]-lastsrvst.srvrpccnt[NFSPROC_LOOKUP], 640 nfsrvstats.srvrpccnt[NFSPROC_READLINK]-lastsrvst.srvrpccnt[NFSPROC_READLINK], 641 nfsrvstats.srvrpccnt[NFSPROC_READ]-lastsrvst.srvrpccnt[NFSPROC_READ], 642 nfsrvstats.srvrpccnt[NFSPROC_WRITE]-lastsrvst.srvrpccnt[NFSPROC_WRITE], 643 nfsrvstats.srvrpccnt[NFSPROC_RENAME]-lastsrvst.srvrpccnt[NFSPROC_RENAME], 644 nfsrvstats.srvrpccnt[NFSPROC_ACCESS]-lastsrvst.srvrpccnt[NFSPROC_ACCESS], 645 (nfsrvstats.srvrpccnt[NFSPROC_READDIR]-lastsrvst.srvrpccnt[NFSPROC_READDIR]) 646 +(nfsrvstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastsrvst.srvrpccnt[NFSPROC_READDIRPLUS])); 647 printf("\n"); 648 lastsrvst = nfsrvstats; 649 } 650 fflush(stdout); 651 sleep(interval); 652 } 653 /*NOTREACHED*/ 654 } 655 656 void 657 printhdr(int clientOnly, int serverOnly) 658 { 659 printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s", 660 ((serverOnly && clientOnly) ? " " : " "), 661 "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename", 662 "Access", "Rddir"); 663 if (widemode && clientOnly) { 664 printf(" Attr Lkup BioR BioW Accs BioD"); 665 } 666 printf("\n"); 667 fflush(stdout); 668 } 669 670 void 671 usage(void) 672 { 673 (void)fprintf(stderr, 674 "usage: nfsstat [-cemoszW] [-M core] [-N system] [-w wait]\n"); 675 exit(1); 676 } 677 678 static char SPBuf[64][8]; 679 static int SPIndex; 680 681 char * 682 sperc1(int hits, int misses) 683 { 684 char *p = SPBuf[SPIndex]; 685 686 if (hits + misses) { 687 sprintf(p, "%3d%%", 688 (int)(char)((quad_t)hits * 100 / (hits + misses))); 689 } else { 690 sprintf(p, " -"); 691 } 692 SPIndex = (SPIndex + 1) & 63; 693 return(p); 694 } 695 696 char * 697 sperc2(int ttl, int misses) 698 { 699 char *p = SPBuf[SPIndex]; 700 701 if (ttl) { 702 sprintf(p, "%3d%%", 703 (int)(char)((quad_t)(ttl - misses) * 100 / ttl)); 704 } else { 705 sprintf(p, " -"); 706 } 707 SPIndex = (SPIndex + 1) & 63; 708 return(p); 709 } 710 711 /* 712 * Print a description of the nfs stats for the experimental client/server. 713 */ 714 void 715 exp_intpr(int clientOnly, int serverOnly) 716 { 717 int nfssvc_flag; 718 719 nfssvc_flag = NFSSVC_GETSTATS; 720 if (zflag != 0) { 721 if (clientOnly != 0) 722 nfssvc_flag |= NFSSVC_ZEROCLTSTATS; 723 if (serverOnly != 0) 724 nfssvc_flag |= NFSSVC_ZEROSRVSTATS; 725 } 726 if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0) 727 err(1, "Can't get stats"); 728 if (clientOnly != 0) { 729 if (printtitle) { 730 printf("Client Info:\n"); 731 printf("Rpc Counts:\n"); 732 printf( 733 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 734 , "Getattr", "Setattr", "Lookup", "Readlink", 735 "Read", "Write", "Create", "Remove"); 736 } 737 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 738 ext_nfsstats.rpccnt[NFSPROC_GETATTR], 739 ext_nfsstats.rpccnt[NFSPROC_SETATTR], 740 ext_nfsstats.rpccnt[NFSPROC_LOOKUP], 741 ext_nfsstats.rpccnt[NFSPROC_READLINK], 742 ext_nfsstats.rpccnt[NFSPROC_READ], 743 ext_nfsstats.rpccnt[NFSPROC_WRITE], 744 ext_nfsstats.rpccnt[NFSPROC_CREATE], 745 ext_nfsstats.rpccnt[NFSPROC_REMOVE]); 746 if (printtitle) 747 printf( 748 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 749 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 750 "Readdir", "RdirPlus", "Access"); 751 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 752 ext_nfsstats.rpccnt[NFSPROC_RENAME], 753 ext_nfsstats.rpccnt[NFSPROC_LINK], 754 ext_nfsstats.rpccnt[NFSPROC_SYMLINK], 755 ext_nfsstats.rpccnt[NFSPROC_MKDIR], 756 ext_nfsstats.rpccnt[NFSPROC_RMDIR], 757 ext_nfsstats.rpccnt[NFSPROC_READDIR], 758 ext_nfsstats.rpccnt[NFSPROC_READDIRPLUS], 759 ext_nfsstats.rpccnt[NFSPROC_ACCESS]); 760 if (printtitle) 761 printf( 762 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 763 , "Mknod", "Fsstat", "Fsinfo", "PathConf", 764 "Commit", "SetClId", "SetClIdCf", "Lock"); 765 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 766 ext_nfsstats.rpccnt[NFSPROC_MKNOD], 767 ext_nfsstats.rpccnt[NFSPROC_FSSTAT], 768 ext_nfsstats.rpccnt[NFSPROC_FSINFO], 769 ext_nfsstats.rpccnt[NFSPROC_PATHCONF], 770 ext_nfsstats.rpccnt[NFSPROC_COMMIT], 771 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTID], 772 ext_nfsstats.rpccnt[NFSPROC_SETCLIENTIDCFRM], 773 ext_nfsstats.rpccnt[NFSPROC_LOCK]); 774 if (printtitle) 775 printf("%9.9s %9.9s %9.9s %9.9s\n", 776 "LockT", "LockU", "Open", "OpenCfr"); 777 printf("%9d %9d %9d %9d\n", 778 ext_nfsstats.rpccnt[NFSPROC_LOCKT], 779 ext_nfsstats.rpccnt[NFSPROC_LOCKU], 780 ext_nfsstats.rpccnt[NFSPROC_OPEN], 781 ext_nfsstats.rpccnt[NFSPROC_OPENCONFIRM]); 782 if (printtitle) 783 printf( 784 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 785 , "OpenOwner", "Opens", "LockOwner", 786 "Locks", "Delegs", "LocalOwn", 787 "LocalOpen", "LocalLOwn"); 788 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 789 ext_nfsstats.clopenowners, 790 ext_nfsstats.clopens, 791 ext_nfsstats.cllockowners, 792 ext_nfsstats.cllocks, 793 ext_nfsstats.cldelegates, 794 ext_nfsstats.cllocalopenowners, 795 ext_nfsstats.cllocalopens, 796 ext_nfsstats.cllocallockowners); 797 if (printtitle) 798 printf("%9.9s\n", "LocalLock"); 799 printf("%9d\n", ext_nfsstats.cllocallocks); 800 if (printtitle) { 801 printf("Rpc Info:\n"); 802 printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n", 803 "TimedOut", "Invalid", "X Replies", "Retries", 804 "Requests"); 805 } 806 printf("%9d %9d %9d %9d %9d\n", 807 ext_nfsstats.rpctimeouts, 808 ext_nfsstats.rpcinvalid, 809 ext_nfsstats.rpcunexpected, 810 ext_nfsstats.rpcretries, 811 ext_nfsstats.rpcrequests); 812 if (printtitle) { 813 printf("Cache Info:\n"); 814 printf("%9.9s %9.9s %9.9s %9.9s", 815 "Attr Hits", "Misses", "Lkup Hits", "Misses"); 816 printf(" %9.9s %9.9s %9.9s %9.9s\n", 817 "BioR Hits", "Misses", "BioW Hits", "Misses"); 818 } 819 printf("%9d %9d %9d %9d", 820 ext_nfsstats.attrcache_hits, 821 ext_nfsstats.attrcache_misses, 822 ext_nfsstats.lookupcache_hits, 823 ext_nfsstats.lookupcache_misses); 824 printf(" %9d %9d %9d %9d\n", 825 ext_nfsstats.biocache_reads - ext_nfsstats.read_bios, 826 ext_nfsstats.read_bios, 827 ext_nfsstats.biocache_writes - ext_nfsstats.write_bios, 828 ext_nfsstats.write_bios); 829 if (printtitle) { 830 printf("%9.9s %9.9s %9.9s %9.9s", 831 "BioRLHits", "Misses", "BioD Hits", "Misses"); 832 printf(" %9.9s %9.9s\n", "DirE Hits", "Misses"); 833 } 834 printf("%9d %9d %9d %9d", 835 ext_nfsstats.biocache_readlinks - 836 ext_nfsstats.readlink_bios, 837 ext_nfsstats.readlink_bios, 838 ext_nfsstats.biocache_readdirs - 839 ext_nfsstats.readdir_bios, 840 ext_nfsstats.readdir_bios); 841 printf(" %9d %9d\n", 842 ext_nfsstats.direofcache_hits, 843 ext_nfsstats.direofcache_misses); 844 } 845 if (serverOnly != 0) { 846 if (printtitle) { 847 printf("\nServer Info:\n"); 848 printf( 849 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 850 , "Getattr", "Setattr", "Lookup", "Readlink", 851 "Read", "Write", "Create", "Remove"); 852 } 853 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 854 ext_nfsstats.srvrpccnt[NFSV4OP_GETATTR], 855 ext_nfsstats.srvrpccnt[NFSV4OP_SETATTR], 856 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUP], 857 ext_nfsstats.srvrpccnt[NFSV4OP_READLINK], 858 ext_nfsstats.srvrpccnt[NFSV4OP_READ], 859 ext_nfsstats.srvrpccnt[NFSV4OP_WRITE], 860 ext_nfsstats.srvrpccnt[NFSV4OP_V3CREATE], 861 ext_nfsstats.srvrpccnt[NFSV4OP_REMOVE]); 862 if (printtitle) 863 printf( 864 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 865 , "Rename", "Link", "Symlink", "Mkdir", "Rmdir", 866 "Readdir", "RdirPlus", "Access"); 867 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 868 ext_nfsstats.srvrpccnt[NFSV4OP_RENAME], 869 ext_nfsstats.srvrpccnt[NFSV4OP_LINK], 870 ext_nfsstats.srvrpccnt[NFSV4OP_SYMLINK], 871 ext_nfsstats.srvrpccnt[NFSV4OP_MKDIR], 872 ext_nfsstats.srvrpccnt[NFSV4OP_RMDIR], 873 ext_nfsstats.srvrpccnt[NFSV4OP_READDIR], 874 ext_nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS], 875 ext_nfsstats.srvrpccnt[NFSV4OP_ACCESS]); 876 if (printtitle) 877 printf( 878 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 879 , "Mknod", "Fsstat", "Fsinfo", "PathConf", 880 "Commit", "LookupP", "SetClId", "SetClIdCf"); 881 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 882 ext_nfsstats.srvrpccnt[NFSV4OP_MKNOD], 883 ext_nfsstats.srvrpccnt[NFSV4OP_FSSTAT], 884 ext_nfsstats.srvrpccnt[NFSV4OP_FSINFO], 885 ext_nfsstats.srvrpccnt[NFSV4OP_PATHCONF], 886 ext_nfsstats.srvrpccnt[NFSV4OP_COMMIT], 887 ext_nfsstats.srvrpccnt[NFSV4OP_LOOKUPP], 888 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTID], 889 ext_nfsstats.srvrpccnt[NFSV4OP_SETCLIENTIDCFRM]); 890 if (printtitle) 891 printf( 892 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 893 , "Open", "OpenAttr", "OpenDwnGr", "OpenCfrm", 894 "DelePurge", "DeleRet", "GetFH", "Lock"); 895 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 896 ext_nfsstats.srvrpccnt[NFSV4OP_OPEN], 897 ext_nfsstats.srvrpccnt[NFSV4OP_OPENATTR], 898 ext_nfsstats.srvrpccnt[NFSV4OP_OPENDOWNGRADE], 899 ext_nfsstats.srvrpccnt[NFSV4OP_OPENCONFIRM], 900 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGPURGE], 901 ext_nfsstats.srvrpccnt[NFSV4OP_DELEGRETURN], 902 ext_nfsstats.srvrpccnt[NFSV4OP_GETFH], 903 ext_nfsstats.srvrpccnt[NFSV4OP_LOCK]); 904 if (printtitle) 905 printf( 906 "%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n" 907 , "LockT", "LockU", "Close", "Verify", "NVerify", 908 "PutFH", "PutPubFH", "PutRootFH"); 909 printf("%9d %9d %9d %9d %9d %9d %9d %9d\n", 910 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKT], 911 ext_nfsstats.srvrpccnt[NFSV4OP_LOCKU], 912 ext_nfsstats.srvrpccnt[NFSV4OP_CLOSE], 913 ext_nfsstats.srvrpccnt[NFSV4OP_VERIFY], 914 ext_nfsstats.srvrpccnt[NFSV4OP_NVERIFY], 915 ext_nfsstats.srvrpccnt[NFSV4OP_PUTFH], 916 ext_nfsstats.srvrpccnt[NFSV4OP_PUTPUBFH], 917 ext_nfsstats.srvrpccnt[NFSV4OP_PUTROOTFH]); 918 if (printtitle) 919 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 920 "Renew", "RestoreFH", "SaveFH", "Secinfo", 921 "RelLckOwn", "V4Create"); 922 printf("%9d %9d %9d %9d %9d %9d\n", 923 ext_nfsstats.srvrpccnt[NFSV4OP_RENEW], 924 ext_nfsstats.srvrpccnt[NFSV4OP_RESTOREFH], 925 ext_nfsstats.srvrpccnt[NFSV4OP_SAVEFH], 926 ext_nfsstats.srvrpccnt[NFSV4OP_SECINFO], 927 ext_nfsstats.srvrpccnt[NFSV4OP_RELEASELCKOWN], 928 ext_nfsstats.srvrpccnt[NFSV4OP_CREATE]); 929 if (printtitle) { 930 printf("Server:\n"); 931 printf("%9.9s %9.9s %9.9s\n", 932 "Retfailed", "Faults", "Clients"); 933 } 934 printf("%9d %9d %9d\n", 935 ext_nfsstats.srv_errs, ext_nfsstats.srvrpc_errs, 936 ext_nfsstats.srvclients); 937 if (printtitle) 938 printf("%9.9s %9.9s %9.9s %9.9s %9.9s \n", 939 "OpenOwner", "Opens", "LockOwner", 940 "Locks", "Delegs"); 941 printf("%9d %9d %9d %9d %9d \n", 942 ext_nfsstats.srvopenowners, 943 ext_nfsstats.srvopens, 944 ext_nfsstats.srvlockowners, 945 ext_nfsstats.srvlocks, 946 ext_nfsstats.srvdelegates); 947 if (printtitle) { 948 printf("Server Cache Stats:\n"); 949 printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n", 950 "Inprog", "Idem", "Non-idem", "Misses", 951 "CacheSize", "TCPPeak"); 952 } 953 printf("%9d %9d %9d %9d %9d %9d\n", 954 ext_nfsstats.srvcache_inproghits, 955 ext_nfsstats.srvcache_idemdonehits, 956 ext_nfsstats.srvcache_nonidemdonehits, 957 ext_nfsstats.srvcache_misses, 958 ext_nfsstats.srvcache_size, 959 ext_nfsstats.srvcache_tcppeak); 960 } 961 } 962 963 /* 964 * Print a running summary of nfs statistics for the experimental client and/or 965 * server. 966 * Repeat display every interval seconds, showing statistics 967 * collected over that interval. Assumes that interval is non-zero. 968 * First line printed at top of screen is always cumulative. 969 */ 970 void 971 exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly) 972 { 973 struct ext_nfsstats nfsstats, lastst, *ext_nfsstatsp; 974 int hdrcnt = 1; 975 976 ext_nfsstatsp = &lastst; 977 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) 978 err(1, "Can't get stats"); 979 sleep(interval); 980 981 for (;;) { 982 ext_nfsstatsp = &nfsstats; 983 if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) 984 err(1, "Can't get stats"); 985 986 if (--hdrcnt == 0) { 987 printhdr(clientOnly, serverOnly); 988 if (clientOnly && serverOnly) 989 hdrcnt = 10; 990 else 991 hdrcnt = 20; 992 } 993 if (clientOnly) { 994 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 995 ((clientOnly && serverOnly) ? "Client:" : ""), 996 DELTA(attrcache_hits) + DELTA(attrcache_misses), 997 DELTA(lookupcache_hits) + DELTA(lookupcache_misses), 998 DELTA(biocache_readlinks), 999 DELTA(biocache_reads), 1000 DELTA(biocache_writes), 1001 nfsstats.rpccnt[NFSPROC_RENAME] - 1002 lastst.rpccnt[NFSPROC_RENAME], 1003 DELTA(accesscache_hits) + DELTA(accesscache_misses), 1004 DELTA(biocache_readdirs) 1005 ); 1006 if (widemode) { 1007 printf(" %s %s %s %s %s %s", 1008 sperc1(DELTA(attrcache_hits), 1009 DELTA(attrcache_misses)), 1010 sperc1(DELTA(lookupcache_hits), 1011 DELTA(lookupcache_misses)), 1012 sperc2(DELTA(biocache_reads), 1013 DELTA(read_bios)), 1014 sperc2(DELTA(biocache_writes), 1015 DELTA(write_bios)), 1016 sperc1(DELTA(accesscache_hits), 1017 DELTA(accesscache_misses)), 1018 sperc2(DELTA(biocache_readdirs), 1019 DELTA(readdir_bios)) 1020 ); 1021 } 1022 printf("\n"); 1023 } 1024 if (serverOnly) { 1025 printf("%s %6d %6d %6d %6d %6d %6d %6d %6d", 1026 ((clientOnly && serverOnly) ? "Server:" : ""), 1027 nfsstats.srvrpccnt[NFSV4OP_GETATTR] - 1028 lastst.srvrpccnt[NFSV4OP_GETATTR], 1029 nfsstats.srvrpccnt[NFSV4OP_LOOKUP] - 1030 lastst.srvrpccnt[NFSV4OP_LOOKUP], 1031 nfsstats.srvrpccnt[NFSV4OP_READLINK] - 1032 lastst.srvrpccnt[NFSV4OP_READLINK], 1033 nfsstats.srvrpccnt[NFSV4OP_READ] - 1034 lastst.srvrpccnt[NFSV4OP_READ], 1035 nfsstats.srvrpccnt[NFSV4OP_WRITE] - 1036 lastst.srvrpccnt[NFSV4OP_WRITE], 1037 nfsstats.srvrpccnt[NFSV4OP_RENAME] - 1038 lastst.srvrpccnt[NFSV4OP_RENAME], 1039 nfsstats.srvrpccnt[NFSV4OP_ACCESS] - 1040 lastst.srvrpccnt[NFSV4OP_ACCESS], 1041 (nfsstats.srvrpccnt[NFSV4OP_READDIR] - 1042 lastst.srvrpccnt[NFSV4OP_READDIR]) + 1043 (nfsstats.srvrpccnt[NFSV4OP_READDIRPLUS] - 1044 lastst.srvrpccnt[NFSV4OP_READDIRPLUS])); 1045 printf("\n"); 1046 } 1047 lastst = nfsstats; 1048 fflush(stdout); 1049 sleep(interval); 1050 } 1051 /*NOTREACHED*/ 1052 } 1053 1054