Home | History | Annotate | Line # | Download | only in nfsstat
nfsstat.c revision 1.12
      1  1.12   msaitoh /*	$NetBSD: nfsstat.c,v 1.12 1998/07/03 15:49:25 msaitoh Exp $	*/
      2   1.7   thorpej 
      3   1.1       cgd /*
      4   1.5   mycroft  * Copyright (c) 1983, 1989, 1993
      5   1.5   mycroft  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * This code is derived from software contributed to Berkeley by
      8   1.1       cgd  * Rick Macklem at The University of Guelph.
      9   1.1       cgd  *
     10   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11   1.1       cgd  * modification, are permitted provided that the following conditions
     12   1.1       cgd  * are met:
     13   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     19   1.1       cgd  *    must display the following acknowledgement:
     20   1.1       cgd  *	This product includes software developed by the University of
     21   1.1       cgd  *	California, Berkeley and its contributors.
     22   1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     23   1.1       cgd  *    may be used to endorse or promote products derived from this software
     24   1.1       cgd  *    without specific prior written permission.
     25   1.1       cgd  *
     26   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.1       cgd  * SUCH DAMAGE.
     37   1.1       cgd  */
     38   1.1       cgd 
     39   1.9     lukem #include <sys/cdefs.h>
     40   1.1       cgd #ifndef lint
     41   1.9     lukem __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1993\n\
     42   1.9     lukem 	The Regents of the University of California.  All rights reserved.\n");
     43   1.1       cgd #endif /* not lint */
     44   1.1       cgd 
     45   1.1       cgd #ifndef lint
     46   1.7   thorpej #if 0
     47   1.7   thorpej static char sccsid[] = "from: @(#)nfsstat.c	8.1 (Berkeley) 6/6/93";
     48   1.7   thorpej #else
     49  1.12   msaitoh __RCSID("$NetBSD: nfsstat.c,v 1.12 1998/07/03 15:49:25 msaitoh Exp $");
     50   1.7   thorpej #endif
     51   1.1       cgd #endif /* not lint */
     52   1.1       cgd 
     53   1.1       cgd #include <sys/param.h>
     54   1.1       cgd #include <sys/mount.h>
     55   1.6      fvdl #include <sys/sysctl.h>
     56   1.8  explorer 
     57   1.6      fvdl #include <nfs/rpcv2.h>
     58   1.6      fvdl #include <nfs/nfsproto.h>
     59   1.1       cgd #include <nfs/nfs.h>
     60   1.8  explorer 
     61   1.1       cgd #include <ctype.h>
     62   1.8  explorer #include <err.h>
     63   1.1       cgd #include <errno.h>
     64   1.8  explorer #include <fcntl.h>
     65   1.5   mycroft #include <kvm.h>
     66   1.8  explorer #include <limits.h>
     67   1.1       cgd #include <nlist.h>
     68   1.8  explorer #include <paths.h>
     69   1.8  explorer #include <signal.h>
     70   1.8  explorer #include <stdlib.h>
     71   1.1       cgd #include <stdio.h>
     72   1.1       cgd #include <string.h>
     73   1.8  explorer #include <unistd.h>
     74   1.1       cgd 
     75   1.1       cgd struct nlist nl[] = {
     76   1.1       cgd #define	N_NFSSTAT	0
     77   1.1       cgd 	{ "_nfsstats" },
     78   1.9     lukem 	{ "" },
     79   1.1       cgd };
     80   1.5   mycroft kvm_t *kd;
     81   1.1       cgd 
     82   1.9     lukem void	catchalarm __P((int));
     83   1.9     lukem void	intpr __P((u_long));
     84   1.9     lukem int	main __P((int, char **));
     85   1.9     lukem void	printhdr __P((void));
     86   1.9     lukem void	sidewaysintpr __P((u_int, u_long));
     87   1.9     lukem void	usage __P((void));
     88   1.1       cgd 
     89  1.10   hubertf int     printall, clientinfo, serverinfo;
     90  1.10   hubertf 
     91   1.9     lukem int
     92   1.1       cgd main(argc, argv)
     93   1.1       cgd 	int argc;
     94   1.1       cgd 	char **argv;
     95   1.1       cgd {
     96   1.1       cgd 	extern int optind;
     97   1.1       cgd 	extern char *optarg;
     98   1.1       cgd 	u_int interval;
     99   1.1       cgd 	int ch;
    100   1.5   mycroft 	char *memf, *nlistf;
    101   1.8  explorer 	char errbuf[_POSIX2_LINE_MAX];
    102   1.1       cgd 
    103   1.1       cgd 	interval = 0;
    104   1.5   mycroft 	memf = nlistf = NULL;
    105  1.10   hubertf 	printall = 1;
    106  1.10   hubertf 	while ((ch = getopt(argc, argv, "M:N:w:cs")) != -1)
    107   1.1       cgd 		switch(ch) {
    108   1.1       cgd 		case 'M':
    109   1.5   mycroft 			memf = optarg;
    110   1.1       cgd 			break;
    111   1.1       cgd 		case 'N':
    112   1.5   mycroft 			nlistf = optarg;
    113   1.1       cgd 			break;
    114   1.1       cgd 		case 'w':
    115   1.1       cgd 			interval = atoi(optarg);
    116   1.1       cgd 			break;
    117  1.10   hubertf 		case 's':
    118  1.10   hubertf 		        serverinfo = 1;
    119  1.10   hubertf 			printall = 0;
    120  1.10   hubertf 			break;
    121  1.10   hubertf 		case 'c':
    122  1.10   hubertf 		        clientinfo = 1;
    123  1.10   hubertf 			printall = 0;
    124  1.10   hubertf 			break;
    125   1.1       cgd 		case '?':
    126   1.1       cgd 		default:
    127   1.1       cgd 			usage();
    128   1.1       cgd 		}
    129   1.1       cgd 	argc -= optind;
    130   1.1       cgd 	argv += optind;
    131   1.1       cgd 
    132   1.1       cgd #define	BACKWARD_COMPATIBILITY
    133   1.1       cgd #ifdef	BACKWARD_COMPATIBILITY
    134   1.1       cgd 	if (*argv) {
    135   1.5   mycroft 		interval = atoi(*argv);
    136   1.1       cgd 		if (*++argv) {
    137   1.5   mycroft 			nlistf = *argv;
    138   1.5   mycroft 			if (*++argv)
    139   1.5   mycroft 				memf = *argv;
    140   1.1       cgd 		}
    141   1.1       cgd 	}
    142   1.1       cgd #endif
    143   1.5   mycroft 	/*
    144   1.5   mycroft 	 * Discard setgid privileges if not the running kernel so that bad
    145   1.5   mycroft 	 * guys can't print interesting stuff from kernel memory.
    146   1.5   mycroft 	 */
    147   1.5   mycroft 	if (nlistf != NULL || memf != NULL)
    148   1.5   mycroft 		setgid(getgid());
    149   1.5   mycroft 
    150   1.9     lukem 	if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == 0)
    151   1.9     lukem 		errx(1, "kvm_openfiles: %s", errbuf);
    152   1.9     lukem 	if (kvm_nlist(kd, nl) != 0)
    153   1.9     lukem 		errx(1, "kvm_nlist: can't get names");
    154   1.1       cgd 
    155   1.1       cgd 	if (interval)
    156   1.5   mycroft 		sidewaysintpr(interval, nl[N_NFSSTAT].n_value);
    157   1.1       cgd 	else
    158   1.5   mycroft 		intpr(nl[N_NFSSTAT].n_value);
    159   1.1       cgd 	exit(0);
    160   1.1       cgd }
    161   1.1       cgd 
    162   1.1       cgd /*
    163   1.5   mycroft  * Print a description of the nfs stats.
    164   1.1       cgd  */
    165   1.1       cgd void
    166   1.1       cgd intpr(nfsstataddr)
    167   1.5   mycroft 	u_long nfsstataddr;
    168   1.1       cgd {
    169   1.1       cgd 	struct nfsstats nfsstats;
    170   1.1       cgd 
    171  1.12   msaitoh 	if (kvm_read(kd, (u_long)nfsstataddr, (char *)&nfsstats,
    172  1.12   msaitoh 				 sizeof(struct nfsstats)) != sizeof(struct nfsstats))
    173   1.9     lukem 		errx(1, "kvm_read failed");
    174  1.10   hubertf 	if (printall || clientinfo){
    175  1.10   hubertf 	  printf("Client Info:\n");
    176  1.10   hubertf 	  printf("Rpc Counts:\n");
    177  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    178   1.1       cgd 		"Getattr", "Setattr", "Lookup", "Readlink", "Read",
    179  1.10   hubertf 		 "Write", "Create", "Remove");
    180  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    181  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_GETATTR],
    182  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_SETATTR],
    183  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_LOOKUP],
    184  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_READLINK],
    185  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_READ],
    186  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_WRITE],
    187  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_CREATE],
    188  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_REMOVE]);
    189  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    190  1.10   hubertf 		 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
    191  1.10   hubertf 		 "Readdir", "RdirPlus", "Access");
    192  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    193  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_RENAME],
    194  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_LINK],
    195  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_SYMLINK],
    196  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_MKDIR],
    197  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_RMDIR],
    198  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_READDIR],
    199  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_READDIRPLUS],
    200  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_ACCESS]);
    201  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    202  1.10   hubertf 		 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
    203  1.10   hubertf 		 "GLease", "Vacate", "Evict");
    204  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    205  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_MKNOD],
    206  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_FSSTAT],
    207  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_FSINFO],
    208  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_PATHCONF],
    209  1.10   hubertf 		 nfsstats.rpccnt[NFSPROC_COMMIT],
    210  1.10   hubertf 		 nfsstats.rpccnt[NQNFSPROC_GETLEASE],
    211  1.10   hubertf 		 nfsstats.rpccnt[NQNFSPROC_VACATED],
    212  1.10   hubertf 		 nfsstats.rpccnt[NQNFSPROC_EVICTED]);
    213  1.10   hubertf 	  printf("Rpc Info:\n");
    214  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
    215  1.10   hubertf 		 "TimedOut", "Invalid", "X Replies", "Retries", "Requests");
    216  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d\n",
    217  1.10   hubertf 		 nfsstats.rpctimeouts,
    218  1.10   hubertf 		 nfsstats.rpcinvalid,
    219  1.10   hubertf 		 nfsstats.rpcunexpected,
    220  1.10   hubertf 		 nfsstats.rpcretries,
    221  1.10   hubertf 		 nfsstats.rpcrequests);
    222  1.10   hubertf 	  printf("Cache Info:\n");
    223  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s",
    224  1.10   hubertf 		 "Attr Hits", "Misses", "Lkup Hits", "Misses");
    225  1.10   hubertf 	  printf(" %9.9s %9.9s %9.9s %9.9s\n",
    226  1.10   hubertf 		 "BioR Hits", "Misses", "BioW Hits", "Misses");
    227  1.10   hubertf 	  printf("%9d %9d %9d %9d",
    228  1.10   hubertf 		 nfsstats.attrcache_hits, nfsstats.attrcache_misses,
    229  1.10   hubertf 		 nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
    230  1.10   hubertf 	  printf(" %9d %9d %9d %9d\n",
    231  1.10   hubertf 		 nfsstats.biocache_reads-nfsstats.read_bios,
    232  1.10   hubertf 		 nfsstats.read_bios,
    233  1.10   hubertf 		 nfsstats.biocache_writes-nfsstats.write_bios,
    234  1.10   hubertf 		 nfsstats.write_bios);
    235  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s",
    236  1.10   hubertf 		 "BioRLHits", "Misses", "BioD Hits", "Misses");
    237  1.10   hubertf 	  printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
    238  1.10   hubertf 	  printf("%9d %9d %9d %9d",
    239  1.10   hubertf 		 nfsstats.biocache_readlinks-nfsstats.readlink_bios,
    240  1.10   hubertf 		 nfsstats.readlink_bios,
    241  1.10   hubertf 		 nfsstats.biocache_readdirs-nfsstats.readdir_bios,
    242  1.10   hubertf 		 nfsstats.readdir_bios);
    243  1.10   hubertf 	  printf(" %9d %9d\n",
    244  1.10   hubertf 		 nfsstats.direofcache_hits, nfsstats.direofcache_misses);
    245  1.10   hubertf 	}
    246  1.10   hubertf 	if (printall || (clientinfo && serverinfo)){
    247  1.10   hubertf 	  printf("\n");
    248  1.10   hubertf 	}
    249  1.10   hubertf 	if (printall || serverinfo){
    250  1.10   hubertf 	  printf("Server Info:\n");
    251  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    252  1.10   hubertf 		 "Getattr", "Setattr", "Lookup", "Readlink", "Read",
    253  1.10   hubertf 		 "Write", "Create", "Remove");
    254  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    255  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_GETATTR],
    256  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_SETATTR],
    257  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_LOOKUP],
    258  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_READLINK],
    259  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_READ],
    260  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_WRITE],
    261  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_CREATE],
    262  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_REMOVE]);
    263  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    264  1.10   hubertf 		 "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
    265  1.10   hubertf 		 "Readdir", "RdirPlus", "Access");
    266  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    267  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_RENAME],
    268  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_LINK],
    269  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_SYMLINK],
    270  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_MKDIR],
    271  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_RMDIR],
    272  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_READDIR],
    273  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_READDIRPLUS],
    274  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_ACCESS]);
    275  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
    276  1.10   hubertf 		 "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
    277  1.10   hubertf 		 "GLease", "Vacate", "Evict");
    278  1.10   hubertf 	  printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
    279  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_MKNOD],
    280  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_FSSTAT],
    281  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_FSINFO],
    282  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_PATHCONF],
    283  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_COMMIT],
    284  1.10   hubertf 		 nfsstats.srvrpccnt[NQNFSPROC_GETLEASE],
    285  1.10   hubertf 		 nfsstats.srvrpccnt[NQNFSPROC_VACATED],
    286  1.10   hubertf 		 nfsstats.srvrpccnt[NQNFSPROC_EVICTED]);
    287  1.10   hubertf 	  printf("Server Ret-Failed\n");
    288  1.10   hubertf 	  printf("%17d\n", nfsstats.srvrpc_errs);
    289  1.10   hubertf 	  printf("Server Faults\n");
    290  1.10   hubertf 	  printf("%13d\n", nfsstats.srv_errs);
    291  1.10   hubertf 	  printf("Server Cache Stats:\n");
    292  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s %9.9s\n",
    293  1.10   hubertf 		 "Inprog", "Idem", "Non-idem", "Misses");
    294  1.10   hubertf 	  printf("%9d %9d %9d %9d\n",
    295  1.10   hubertf 		 nfsstats.srvcache_inproghits,
    296  1.10   hubertf 		 nfsstats.srvcache_idemdonehits,
    297  1.10   hubertf 		 nfsstats.srvcache_nonidemdonehits,
    298  1.10   hubertf 		 nfsstats.srvcache_misses);
    299  1.10   hubertf 	  printf("Server Lease Stats:\n");
    300  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s\n",
    301  1.10   hubertf 		 "Leases", "PeakL", "GLeases");
    302  1.10   hubertf 	  printf("%9d %9d %9d\n",
    303  1.10   hubertf 		 nfsstats.srvnqnfs_leases,
    304  1.10   hubertf 		 nfsstats.srvnqnfs_maxleases,
    305  1.10   hubertf 		 nfsstats.srvnqnfs_getleases);
    306  1.10   hubertf 	  printf("Server Write Gathering:\n");
    307  1.10   hubertf 	  printf("%9.9s %9.9s %9.9s\n",
    308  1.10   hubertf 		 "WriteOps", "WriteRPC", "Opsaved");
    309  1.10   hubertf 	  printf("%9d %9d %9d\n",
    310  1.10   hubertf 		 nfsstats.srvvop_writes,
    311  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_WRITE],
    312  1.10   hubertf 		 nfsstats.srvrpccnt[NFSPROC_WRITE] - nfsstats.srvvop_writes);
    313  1.10   hubertf 	}
    314   1.1       cgd }
    315   1.1       cgd 
    316   1.1       cgd u_char	signalled;			/* set if alarm goes off "early" */
    317   1.1       cgd 
    318   1.1       cgd /*
    319   1.1       cgd  * Print a running summary of nfs statistics.
    320   1.1       cgd  * Repeat display every interval seconds, showing statistics
    321   1.1       cgd  * collected over that interval.  Assumes that interval is non-zero.
    322   1.1       cgd  * First line printed at top of screen is always cumulative.
    323   1.1       cgd  */
    324   1.1       cgd void
    325   1.1       cgd sidewaysintpr(interval, off)
    326   1.1       cgd 	u_int interval;
    327   1.5   mycroft 	u_long off;
    328   1.1       cgd {
    329   1.1       cgd 	struct nfsstats nfsstats, lastst;
    330   1.1       cgd 	int hdrcnt, oldmask;
    331   1.1       cgd 
    332   1.1       cgd 	(void)signal(SIGALRM, catchalarm);
    333   1.1       cgd 	signalled = 0;
    334   1.1       cgd 	(void)alarm(interval);
    335   1.9     lukem 	memset((caddr_t)&lastst, 0, sizeof(lastst));
    336   1.1       cgd 
    337   1.1       cgd 	for (hdrcnt = 1;;) {
    338   1.1       cgd 		if (!--hdrcnt) {
    339   1.1       cgd 			printhdr();
    340   1.1       cgd 			hdrcnt = 20;
    341   1.1       cgd 		}
    342  1.12   msaitoh 		if (kvm_read(kd, off, (char *)&nfsstats, sizeof(nfsstats))
    343  1.12   msaitoh 			!= sizeof(nfsstats))
    344   1.9     lukem 			errx(1, "kvm_read failed");
    345  1.10   hubertf 		if (printall || clientinfo)
    346  1.10   hubertf 		  printf("Client: %8d %8d %8d %8d %8d %8d %8d %8d\n",
    347  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_GETATTR]-lastst.rpccnt[NFSPROC_GETATTR],
    348  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_LOOKUP]-lastst.rpccnt[NFSPROC_LOOKUP],
    349  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_READLINK]-lastst.rpccnt[NFSPROC_READLINK],
    350  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_READ]-lastst.rpccnt[NFSPROC_READ],
    351  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_WRITE]-lastst.rpccnt[NFSPROC_WRITE],
    352  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_RENAME]-lastst.rpccnt[NFSPROC_RENAME],
    353  1.10   hubertf 			 nfsstats.rpccnt[NFSPROC_ACCESS]-lastst.rpccnt[NFSPROC_ACCESS],
    354  1.10   hubertf 			 (nfsstats.rpccnt[NFSPROC_READDIR]-lastst.rpccnt[NFSPROC_READDIR])
    355  1.10   hubertf 			 +(nfsstats.rpccnt[NFSPROC_READDIRPLUS]-lastst.rpccnt[NFSPROC_READDIRPLUS]));
    356  1.10   hubertf 		if (printall || serverinfo)
    357   1.1       cgd 		printf("Server: %8d %8d %8d %8d %8d %8d %8d %8d\n",
    358  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_GETATTR]-lastst.srvrpccnt[NFSPROC_GETATTR],
    359  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_LOOKUP]-lastst.srvrpccnt[NFSPROC_LOOKUP],
    360  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_READLINK]-lastst.srvrpccnt[NFSPROC_READLINK],
    361  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_READ]-lastst.srvrpccnt[NFSPROC_READ],
    362  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_WRITE]-lastst.srvrpccnt[NFSPROC_WRITE],
    363  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_RENAME]-lastst.srvrpccnt[NFSPROC_RENAME],
    364  1.10   hubertf 		       nfsstats.srvrpccnt[NFSPROC_ACCESS]-lastst.srvrpccnt[NFSPROC_ACCESS],
    365  1.10   hubertf 		       (nfsstats.srvrpccnt[NFSPROC_READDIR]-lastst.srvrpccnt[NFSPROC_READDIR])
    366  1.10   hubertf 		       +(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS]-lastst.srvrpccnt[NFSPROC_READDIRPLUS]));
    367   1.1       cgd 		lastst = nfsstats;
    368   1.1       cgd 		fflush(stdout);
    369   1.1       cgd 		oldmask = sigblock(sigmask(SIGALRM));
    370   1.1       cgd 		if (!signalled)
    371   1.1       cgd 			sigpause(0);
    372   1.1       cgd 		sigsetmask(oldmask);
    373   1.1       cgd 		signalled = 0;
    374   1.1       cgd 		(void)alarm(interval);
    375   1.1       cgd 	}
    376   1.1       cgd 	/*NOTREACHED*/
    377   1.1       cgd }
    378   1.1       cgd 
    379   1.1       cgd void
    380   1.1       cgd printhdr()
    381   1.1       cgd {
    382   1.1       cgd 	printf("        %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s\n",
    383   1.1       cgd 	    "Getattr", "Lookup", "Readlink", "Read", "Write", "Rename",
    384   1.6      fvdl 	    "Access", "Readdir");
    385   1.1       cgd 	fflush(stdout);
    386   1.1       cgd }
    387   1.1       cgd 
    388   1.1       cgd /*
    389   1.1       cgd  * Called if an interval expires before sidewaysintpr has completed a loop.
    390   1.1       cgd  * Sets a flag to not wait for the alarm.
    391   1.1       cgd  */
    392   1.1       cgd void
    393   1.9     lukem catchalarm(dummy)
    394   1.9     lukem 	int dummy;
    395   1.1       cgd {
    396   1.1       cgd 	signalled = 1;
    397   1.1       cgd }
    398   1.1       cgd 
    399   1.1       cgd void
    400   1.1       cgd usage()
    401   1.1       cgd {
    402   1.1       cgd 	(void)fprintf(stderr,
    403  1.11   hubertf 	    "usage: nfsstat [-cs] [-M core] [-N system] [-w interval]\n");
    404   1.1       cgd 	exit(1);
    405   1.1       cgd }
    406