nfsstat.c revision 65428
191396Stmm/*
291396Stmm * Copyright (c) 1983, 1989, 1993
391396Stmm *	The Regents of the University of California.  All rights reserved.
491396Stmm *
591396Stmm * This code is derived from software contributed to Berkeley by
691396Stmm * Rick Macklem at The University of Guelph.
791396Stmm *
891396Stmm * Redistribution and use in source and binary forms, with or without
991396Stmm * modification, are permitted provided that the following conditions
1091396Stmm * are met:
1191396Stmm * 1. Redistributions of source code must retain the above copyright
1291396Stmm *    notice, this list of conditions and the following disclaimer.
1391396Stmm * 2. Redistributions in binary form must reproduce the above copyright
1491396Stmm *    notice, this list of conditions and the following disclaimer in the
1591396Stmm *    documentation and/or other materials provided with the distribution.
1691396Stmm * 3. All advertising materials mentioning features or use of this software
1791396Stmm *    must display the following acknowledgement:
1891396Stmm *	This product includes software developed by the University of
1991396Stmm *	California, Berkeley and its contributors.
2091396Stmm * 4. Neither the name of the University nor the names of its contributors
2191396Stmm *    may be used to endorse or promote products derived from this software
2291396Stmm *    without specific prior written permission.
2391396Stmm *
2491396Stmm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2591396Stmm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2691396Stmm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2791396Stmm * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2891396Stmm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2991396Stmm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3091396Stmm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3191396Stmm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3291396Stmm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3391396Stmm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3491396Stmm * SUCH DAMAGE.
3591396Stmm */
3691396Stmm
3791396Stmm#ifndef lint
3891396Stmmstatic char copyright[] =
3991396Stmm"@(#) Copyright (c) 1983, 1989, 1993\n\
4091396Stmm	The Regents of the University of California.  All rights reserved.\n";
4191396Stmm#endif /* not lint */
4291396Stmm
4391396Stmm#ifndef lint
4491396Stmm#if 0
4591396Stmmstatic char sccsid[] = "@(#)nfsstat.c	8.2 (Berkeley) 3/31/95";
4691396Stmm#endif
4791396Stmmstatic const char rcsid[] =
4891396Stmm  "$FreeBSD: head/usr.bin/nfsstat/nfsstat.c 65428 2000-09-04 06:09:54Z imp $";
4991396Stmm#endif /* not lint */
5091396Stmm
5191396Stmm#include <sys/param.h>
5291396Stmm#include <sys/mount.h>
5391396Stmm#include <sys/time.h>
5491396Stmm#include <sys/sysctl.h>
5591396Stmm#include <nfs/rpcv2.h>
5691396Stmm#include <nfs/nfsproto.h>
5791396Stmm#include <nfs/nfs.h>
5891396Stmm#include <signal.h>
5991396Stmm#include <fcntl.h>
6091396Stmm#include <ctype.h>
6191396Stmm#include <errno.h>
6291396Stmm#include <kvm.h>
6391396Stmm#include <nlist.h>
6491396Stmm#include <unistd.h>
6591396Stmm#include <stdio.h>
6691396Stmm#include <stdlib.h>
6791396Stmm#include <string.h>
6891396Stmm#include <paths.h>
6991396Stmm#include <err.h>
7091396Stmm
7191396Stmmstruct nlist nl[] = {
7291396Stmm#define	N_NFSSTAT	0
7391396Stmm	{ "_nfsstats" },
7491396Stmm	"",
7591396Stmm};
7691396Stmmkvm_t *kd;
7791396Stmm
7891396Stmmstatic int deadkernel = 0;
7991396Stmmstatic int widemode = 0;
8091396Stmm
8191396Stmmvoid intpr __P((int, int));
8291396Stmmvoid printhdr __P((int, int));
8391396Stmmvoid sidewaysintpr __P((u_int, int, int));
8491396Stmmvoid usage __P((void));
8591396Stmmchar *sperc1 __P((int, int));
8691396Stmmchar *sperc2 __P((int, int));
8791396Stmm
8891396Stmm#define DELTA(field)	(nfsstats.field - lastst.field)
8991396Stmm
9091396Stmmmain(argc, argv)
9191396Stmm	int argc;
9291396Stmm	char **argv;
9391396Stmm{
9491396Stmm	u_int interval;
9591396Stmm	int clientOnly = -1;
9691396Stmm	int serverOnly = -1;
9791396Stmm	int ch;
9891396Stmm	char *memf, *nlistf;
9991396Stmm	char errbuf[80];
10091396Stmm
10191396Stmm	interval = 0;
10291396Stmm	memf = nlistf = NULL;
10391396Stmm	while ((ch = getopt(argc, argv, "csWM:N:w:")) != -1)
10491396Stmm		switch(ch) {
10591396Stmm		case 'M':
10691396Stmm			memf = optarg;
10791396Stmm			break;
10891396Stmm		case 'N':
10991396Stmm			nlistf = optarg;
11091396Stmm			break;
11191396Stmm		case 'W':
11291396Stmm			widemode = 1;
11391396Stmm			break;
11491396Stmm		case 'w':
11591396Stmm			interval = atoi(optarg);
11691396Stmm			break;
11791396Stmm		case 'c':
11891396Stmm			clientOnly = 1;
11991396Stmm			if (serverOnly < 0)
12091396Stmm				serverOnly = 0;
12191396Stmm			break;
12291396Stmm		case 's':
12391396Stmm			serverOnly = 1;
12491396Stmm			if (clientOnly < 0)
12591396Stmm				clientOnly = 0;
12691396Stmm			break;
12791396Stmm		case '?':
12891396Stmm		default:
12991396Stmm			usage();
13091396Stmm		}
13191396Stmm	argc -= optind;
13291396Stmm	argv += optind;
13391396Stmm
13491396Stmm#define	BACKWARD_COMPATIBILITY
13591396Stmm#ifdef	BACKWARD_COMPATIBILITY
13691396Stmm	if (*argv) {
13791396Stmm		interval = atoi(*argv);
13891396Stmm		if (*++argv) {
13991396Stmm			nlistf = *argv;
14091396Stmm			if (*++argv)
14191396Stmm				memf = *argv;
14291396Stmm		}
14391396Stmm	}
14491396Stmm#endif
14591396Stmm	/*
14691396Stmm	 * Discard setgid privileges if not the running kernel so that bad
14791396Stmm	 * guys can't print interesting stuff from kernel memory.
14891396Stmm	 */
14991396Stmm	if (nlistf != NULL || memf != NULL) {
15091396Stmm		setgid(getgid());
15191396Stmm		deadkernel = 1;
15291396Stmm
15391396Stmm		if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
15491396Stmm					errbuf)) == 0) {
15591396Stmm			errx(1, "kvm_openfiles: %s", errbuf);
15691396Stmm		}
15791396Stmm		if (kvm_nlist(kd, nl) != 0) {
15891396Stmm			errx(1, "kvm_nlist: can't get names");
15991396Stmm		}
16091396Stmm	}
16191396Stmm
16291396Stmm	if (interval)
16391396Stmm		sidewaysintpr(interval, clientOnly, serverOnly);
16491396Stmm	else
16591396Stmm		intpr(clientOnly, serverOnly);
16691396Stmm	exit(0);
16791396Stmm}
16891396Stmm
16991396Stmm/*
17091396Stmm * Read the nfs stats using sysctl(3) for live kernels, or kvm_read
17191396Stmm * for dead ones.
17291396Stmm */
17391396Stmmvoid
17491396Stmmreadstats(stp)
17591396Stmm	struct nfsstats *stp;
17691396Stmm{
17791396Stmm	if(deadkernel) {
17891396Stmm		if(kvm_read(kd, (u_long)nl[N_NFSSTAT].n_value, stp,
17991396Stmm			    sizeof *stp) < 0) {
18091396Stmm			err(1, "kvm_read");
18191396Stmm		}
18291396Stmm	} else {
18391396Stmm		int name[3];
18491396Stmm		size_t buflen = sizeof *stp;
18591396Stmm		struct vfsconf vfc;
18691396Stmm
18791396Stmm		if (getvfsbyname("nfs", &vfc) < 0)
18891396Stmm			err(1, "getvfsbyname: NFS not compiled into kernel");
18991396Stmm		name[0] = CTL_VFS;
19091396Stmm		name[1] = vfc.vfc_typenum;
19191396Stmm		name[2] = NFS_NFSSTATS;
19291396Stmm		if (sysctl(name, 3, stp, &buflen, (void *)0, (size_t)0) < 0) {
19391396Stmm			err(1, "sysctl");
19491396Stmm		}
19591396Stmm	}
19691396Stmm}
19791396Stmm
19891396Stmm/*
19991396Stmm * Print a description of the nfs stats.
20091396Stmm */
20191396Stmmvoid
20291396Stmmintpr(int clientOnly, int serverOnly)
20391396Stmm{
20491396Stmm	struct nfsstats nfsstats;
20591396Stmm
20691396Stmm	readstats(&nfsstats);
20791396Stmm
20891396Stmm	if (clientOnly) {
20991396Stmm		printf("Client Info:\n");
21091396Stmm		printf("Rpc Counts:\n");
21191396Stmm		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
21291396Stmm			"Getattr", "Setattr", "Lookup", "Readlink", "Read",
21391396Stmm			"Write", "Create", "Remove");
21491396Stmm		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
21591396Stmm			nfsstats.rpccnt[NFSPROC_GETATTR],
21691396Stmm			nfsstats.rpccnt[NFSPROC_SETATTR],
21791396Stmm			nfsstats.rpccnt[NFSPROC_LOOKUP],
21891396Stmm			nfsstats.rpccnt[NFSPROC_READLINK],
21991396Stmm			nfsstats.rpccnt[NFSPROC_READ],
22091396Stmm			nfsstats.rpccnt[NFSPROC_WRITE],
22191396Stmm			nfsstats.rpccnt[NFSPROC_CREATE],
22291396Stmm			nfsstats.rpccnt[NFSPROC_REMOVE]);
22391396Stmm		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
22491396Stmm			"Rename", "Link", "Symlink", "Mkdir", "Rmdir",
22591396Stmm			"Readdir", "RdirPlus", "Access");
22691396Stmm		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
22791396Stmm			nfsstats.rpccnt[NFSPROC_RENAME],
22891396Stmm			nfsstats.rpccnt[NFSPROC_LINK],
22991396Stmm			nfsstats.rpccnt[NFSPROC_SYMLINK],
23091396Stmm			nfsstats.rpccnt[NFSPROC_MKDIR],
23191396Stmm			nfsstats.rpccnt[NFSPROC_RMDIR],
23291396Stmm			nfsstats.rpccnt[NFSPROC_READDIR],
23391396Stmm			nfsstats.rpccnt[NFSPROC_READDIRPLUS],
23491396Stmm			nfsstats.rpccnt[NFSPROC_ACCESS]);
23591396Stmm		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
23691396Stmm			"Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
23791396Stmm			"GLease", "Vacate", "Evict");
23891396Stmm		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
23991396Stmm			nfsstats.rpccnt[NFSPROC_MKNOD],
24091396Stmm			nfsstats.rpccnt[NFSPROC_FSSTAT],
24191396Stmm			nfsstats.rpccnt[NFSPROC_FSINFO],
24291396Stmm			nfsstats.rpccnt[NFSPROC_PATHCONF],
24391396Stmm			nfsstats.rpccnt[NFSPROC_COMMIT],
24491396Stmm			nfsstats.rpccnt[NQNFSPROC_GETLEASE],
24591396Stmm			nfsstats.rpccnt[NQNFSPROC_VACATED],
24691396Stmm			nfsstats.rpccnt[NQNFSPROC_EVICTED]);
24791396Stmm		printf("Rpc Info:\n");
24891396Stmm		printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
24991396Stmm			"TimedOut", "Invalid", "X Replies", "Retries",
25091396Stmm			"Requests");
25191396Stmm		printf("%9d %9d %9d %9d %9d\n",
25291396Stmm			nfsstats.rpctimeouts,
25391396Stmm			nfsstats.rpcinvalid,
25491396Stmm			nfsstats.rpcunexpected,
25591396Stmm			nfsstats.rpcretries,
25691396Stmm			nfsstats.rpcrequests);
25791396Stmm		printf("Cache Info:\n");
25891396Stmm		printf("%9.9s %9.9s %9.9s %9.9s",
25991396Stmm			"Attr Hits", "Misses", "Lkup Hits", "Misses");
26091396Stmm		printf(" %9.9s %9.9s %9.9s %9.9s\n",
26191396Stmm			"BioR Hits", "Misses", "BioW Hits", "Misses");
26291396Stmm		printf("%9d %9d %9d %9d",
26391396Stmm			nfsstats.attrcache_hits, nfsstats.attrcache_misses,
26491396Stmm			nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
26591396Stmm		printf(" %9d %9d %9d %9d\n",
26691396Stmm			nfsstats.biocache_reads-nfsstats.read_bios,
26791396Stmm			nfsstats.read_bios,
26891396Stmm			nfsstats.biocache_writes-nfsstats.write_bios,
26991396Stmm			nfsstats.write_bios);
27091396Stmm		printf("%9.9s %9.9s %9.9s %9.9s",
27191396Stmm			"BioRLHits", "Misses", "BioD Hits", "Misses");
27291396Stmm		printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
27391396Stmm		printf("%9d %9d %9d %9d",
27491396Stmm			nfsstats.biocache_readlinks-nfsstats.readlink_bios,
27591396Stmm			nfsstats.readlink_bios,
27691396Stmm			nfsstats.biocache_readdirs-nfsstats.readdir_bios,
277			nfsstats.readdir_bios);
278		printf(" %9d %9d\n",
279			nfsstats.direofcache_hits, nfsstats.direofcache_misses);
280	}
281	if (serverOnly) {
282		printf("\nServer Info:\n");
283		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
284			"Getattr", "Setattr", "Lookup", "Readlink", "Read",
285			"Write", "Create", "Remove");
286		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
287			nfsstats.srvrpccnt[NFSPROC_GETATTR],
288			nfsstats.srvrpccnt[NFSPROC_SETATTR],
289			nfsstats.srvrpccnt[NFSPROC_LOOKUP],
290			nfsstats.srvrpccnt[NFSPROC_READLINK],
291			nfsstats.srvrpccnt[NFSPROC_READ],
292			nfsstats.srvrpccnt[NFSPROC_WRITE],
293			nfsstats.srvrpccnt[NFSPROC_CREATE],
294			nfsstats.srvrpccnt[NFSPROC_REMOVE]);
295		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
296			"Rename", "Link", "Symlink", "Mkdir", "Rmdir",
297			"Readdir", "RdirPlus", "Access");
298		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
299			nfsstats.srvrpccnt[NFSPROC_RENAME],
300			nfsstats.srvrpccnt[NFSPROC_LINK],
301			nfsstats.srvrpccnt[NFSPROC_SYMLINK],
302			nfsstats.srvrpccnt[NFSPROC_MKDIR],
303			nfsstats.srvrpccnt[NFSPROC_RMDIR],
304			nfsstats.srvrpccnt[NFSPROC_READDIR],
305			nfsstats.srvrpccnt[NFSPROC_READDIRPLUS],
306			nfsstats.srvrpccnt[NFSPROC_ACCESS]);
307		printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
308			"Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
309			"GLease", "Vacate", "Evict");
310		printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
311			nfsstats.srvrpccnt[NFSPROC_MKNOD],
312			nfsstats.srvrpccnt[NFSPROC_FSSTAT],
313			nfsstats.srvrpccnt[NFSPROC_FSINFO],
314			nfsstats.srvrpccnt[NFSPROC_PATHCONF],
315			nfsstats.srvrpccnt[NFSPROC_COMMIT],
316			nfsstats.srvrpccnt[NQNFSPROC_GETLEASE],
317			nfsstats.srvrpccnt[NQNFSPROC_VACATED],
318			nfsstats.srvrpccnt[NQNFSPROC_EVICTED]);
319		printf("Server Ret-Failed\n");
320		printf("%17d\n", nfsstats.srvrpc_errs);
321		printf("Server Faults\n");
322		printf("%13d\n", nfsstats.srv_errs);
323		printf("Server Cache Stats:\n");
324		printf("%9.9s %9.9s %9.9s %9.9s\n",
325			"Inprog", "Idem", "Non-idem", "Misses");
326		printf("%9d %9d %9d %9d\n",
327			nfsstats.srvcache_inproghits,
328			nfsstats.srvcache_idemdonehits,
329			nfsstats.srvcache_nonidemdonehits,
330			nfsstats.srvcache_misses);
331		printf("Server Lease Stats:\n");
332		printf("%9.9s %9.9s %9.9s\n",
333		"Leases", "PeakL", "GLeases");
334		printf("%9d %9d %9d\n",
335			nfsstats.srvnqnfs_leases,
336			nfsstats.srvnqnfs_maxleases,
337			nfsstats.srvnqnfs_getleases);
338		printf("Server Write Gathering:\n");
339		printf("%9.9s %9.9s %9.9s\n",
340			"WriteOps", "WriteRPC", "Opsaved");
341		printf("%9d %9d %9d\n",
342			nfsstats.srvvop_writes,
343			nfsstats.srvrpccnt[NFSPROC_WRITE],
344			nfsstats.srvrpccnt[NFSPROC_WRITE] -
345			    nfsstats.srvvop_writes);
346	}
347}
348
349u_char	signalled;			/* set if alarm goes off "early" */
350
351/*
352 * Print a running summary of nfs statistics.
353 * Repeat display every interval seconds, showing statistics
354 * collected over that interval.  Assumes that interval is non-zero.
355 * First line printed at top of screen is always cumulative.
356 */
357void
358sidewaysintpr(u_int interval, int clientOnly, int serverOnly)
359{
360	struct nfsstats nfsstats, lastst;
361	int hdrcnt = 1;
362
363	readstats(&lastst);
364	sleep(interval);
365
366	for (;;) {
367		readstats(&nfsstats);
368
369		if (--hdrcnt == 0) {
370			printhdr(clientOnly, serverOnly);
371			if (clientOnly && serverOnly)
372				hdrcnt = 10;
373			else
374				hdrcnt = 20;
375		}
376		if (clientOnly) {
377		    printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
378			((clientOnly && serverOnly) ? "Client:" : ""),
379			DELTA(attrcache_hits) + DELTA(attrcache_misses),
380			DELTA(lookupcache_hits) + DELTA(lookupcache_misses),
381			DELTA(biocache_readlinks),
382			DELTA(biocache_reads),
383			DELTA(biocache_writes),
384			nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME],
385			DELTA(accesscache_hits) + DELTA(accesscache_misses),
386			DELTA(biocache_readdirs)
387		    );
388		    if (widemode) {
389			    printf(" %s %s %s %s %s %s",
390				sperc1(DELTA(attrcache_hits),
391				    DELTA(attrcache_misses)),
392				sperc1(DELTA(lookupcache_hits),
393				    DELTA(lookupcache_misses)),
394				sperc2(DELTA(biocache_reads),
395				    DELTA(read_bios)),
396				sperc2(DELTA(biocache_writes),
397				    DELTA(write_bios)),
398				sperc1(DELTA(accesscache_hits),
399				    DELTA(accesscache_misses)),
400				sperc2(DELTA(biocache_readdirs),
401				    DELTA(readdir_bios))
402			    );
403		    }
404		    printf("\n");
405		}
406		if (serverOnly) {
407		    printf("%s %6d %6d %6d %6d %6d %6d %6d %6d",
408			((clientOnly && serverOnly) ? "Server:" : ""),
409			nfsstats.srvrpccnt[NFSPROC_GETATTR]-lastst.srvrpccnt[NFSPROC_GETATTR],
410			nfsstats.srvrpccnt[NFSPROC_LOOKUP]-lastst.srvrpccnt[NFSPROC_LOOKUP],
411			nfsstats.srvrpccnt[NFSPROC_READLINK]-lastst.srvrpccnt[NFSPROC_READLINK],
412			nfsstats.srvrpccnt[NFSPROC_READ]-lastst.srvrpccnt[NFSPROC_READ],
413			nfsstats.srvrpccnt[NFSPROC_WRITE]-lastst.srvrpccnt[NFSPROC_WRITE],
414			nfsstats.srvrpccnt[NFSPROC_RENAME]-lastst.srvrpccnt[NFSPROC_RENAME],
415			nfsstats.srvrpccnt[NFSPROC_ACCESS]-lastst.srvrpccnt[NFSPROC_ACCESS],
416			(nfsstats.srvrpccnt[NFSPROC_READDIR]-lastst.srvrpccnt[NFSPROC_READDIR])
417			+(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastst.srvrpccnt[NFSPROC_READDIRPLUS]));
418		    printf("\n");
419		}
420		lastst = nfsstats;
421		fflush(stdout);
422		sleep(interval);
423	}
424	/*NOTREACHED*/
425}
426
427void
428printhdr(int clientOnly, int serverOnly)
429{
430	printf("%s%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s",
431	    ((serverOnly && clientOnly) ? "        " : " "),
432	    "GtAttr", "Lookup", "Rdlink", "Read", "Write", "Rename",
433	    "Access", "Rddir");
434	if (widemode && clientOnly) {
435		printf(" Attr Lkup BioR BioW Accs BioD");
436	}
437	printf("\n");
438	fflush(stdout);
439}
440
441void
442usage()
443{
444	(void)fprintf(stderr,
445	    "usage: nfsstat [-csW] [-M core] [-N system] [-w interval]\n");
446	exit(1);
447}
448
449static char SPBuf[64][8];
450static int SPIndex;
451
452char *
453sperc1(int hits, int misses)
454{
455	char *p = SPBuf[SPIndex];
456
457	if (hits + misses) {
458		sprintf(p, "%3d%%",
459		    (int)(char)((quad_t)hits * 100 / (hits + misses)));
460	} else {
461		sprintf(p, "   -");
462	}
463	SPIndex = (SPIndex + 1) & 63;
464	return(p);
465}
466
467char *
468sperc2(int ttl, int misses)
469{
470	char *p = SPBuf[SPIndex];
471
472	if (ttl) {
473		sprintf(p, "%3d%%",
474		    (int)(char)((quad_t)(ttl - misses) * 100 / ttl));
475	} else {
476		sprintf(p, "   -");
477	}
478	SPIndex = (SPIndex + 1) & 63;
479	return(p);
480}
481
482