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