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