nfsstat.c revision 1.13 1 1.13 mrg /* $NetBSD: nfsstat.c,v 1.13 1998/07/05 08:15:16 mrg 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.13 mrg __RCSID("$NetBSD: nfsstat.c,v 1.13 1998/07/05 08:15:16 mrg 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.13 mrg setgid(getgid()); /* do this now anyway */
153 1.9 lukem if (kvm_nlist(kd, nl) != 0)
154 1.9 lukem errx(1, "kvm_nlist: can't get names");
155 1.1 cgd
156 1.1 cgd if (interval)
157 1.5 mycroft sidewaysintpr(interval, nl[N_NFSSTAT].n_value);
158 1.1 cgd else
159 1.5 mycroft intpr(nl[N_NFSSTAT].n_value);
160 1.1 cgd exit(0);
161 1.1 cgd }
162 1.1 cgd
163 1.1 cgd /*
164 1.5 mycroft * Print a description of the nfs stats.
165 1.1 cgd */
166 1.1 cgd void
167 1.1 cgd intpr(nfsstataddr)
168 1.5 mycroft u_long nfsstataddr;
169 1.1 cgd {
170 1.1 cgd struct nfsstats nfsstats;
171 1.1 cgd
172 1.12 msaitoh if (kvm_read(kd, (u_long)nfsstataddr, (char *)&nfsstats,
173 1.13 mrg sizeof(struct nfsstats)) != sizeof(struct nfsstats))
174 1.9 lukem errx(1, "kvm_read failed");
175 1.13 mrg if (printall || clientinfo) {
176 1.13 mrg printf("Client Info:\n");
177 1.13 mrg printf("Rpc Counts:\n");
178 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
179 1.13 mrg "Getattr", "Setattr", "Lookup", "Readlink", "Read",
180 1.13 mrg "Write", "Create", "Remove");
181 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
182 1.13 mrg nfsstats.rpccnt[NFSPROC_GETATTR],
183 1.13 mrg nfsstats.rpccnt[NFSPROC_SETATTR],
184 1.13 mrg nfsstats.rpccnt[NFSPROC_LOOKUP],
185 1.13 mrg nfsstats.rpccnt[NFSPROC_READLINK],
186 1.13 mrg nfsstats.rpccnt[NFSPROC_READ],
187 1.13 mrg nfsstats.rpccnt[NFSPROC_WRITE],
188 1.13 mrg nfsstats.rpccnt[NFSPROC_CREATE],
189 1.13 mrg nfsstats.rpccnt[NFSPROC_REMOVE]);
190 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
191 1.13 mrg "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
192 1.13 mrg "Readdir", "RdirPlus", "Access");
193 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
194 1.13 mrg nfsstats.rpccnt[NFSPROC_RENAME],
195 1.13 mrg nfsstats.rpccnt[NFSPROC_LINK],
196 1.13 mrg nfsstats.rpccnt[NFSPROC_SYMLINK],
197 1.13 mrg nfsstats.rpccnt[NFSPROC_MKDIR],
198 1.13 mrg nfsstats.rpccnt[NFSPROC_RMDIR],
199 1.13 mrg nfsstats.rpccnt[NFSPROC_READDIR],
200 1.13 mrg nfsstats.rpccnt[NFSPROC_READDIRPLUS],
201 1.13 mrg nfsstats.rpccnt[NFSPROC_ACCESS]);
202 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
203 1.13 mrg "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
204 1.13 mrg "GLease", "Vacate", "Evict");
205 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
206 1.13 mrg nfsstats.rpccnt[NFSPROC_MKNOD],
207 1.13 mrg nfsstats.rpccnt[NFSPROC_FSSTAT],
208 1.13 mrg nfsstats.rpccnt[NFSPROC_FSINFO],
209 1.13 mrg nfsstats.rpccnt[NFSPROC_PATHCONF],
210 1.13 mrg nfsstats.rpccnt[NFSPROC_COMMIT],
211 1.13 mrg nfsstats.rpccnt[NQNFSPROC_GETLEASE],
212 1.13 mrg nfsstats.rpccnt[NQNFSPROC_VACATED],
213 1.13 mrg nfsstats.rpccnt[NQNFSPROC_EVICTED]);
214 1.13 mrg printf("Rpc Info:\n");
215 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
216 1.13 mrg "TimedOut", "Invalid", "X Replies", "Retries", "Requests");
217 1.13 mrg printf("%9d %9d %9d %9d %9d\n",
218 1.13 mrg nfsstats.rpctimeouts,
219 1.13 mrg nfsstats.rpcinvalid,
220 1.13 mrg nfsstats.rpcunexpected,
221 1.13 mrg nfsstats.rpcretries,
222 1.13 mrg nfsstats.rpcrequests);
223 1.13 mrg printf("Cache Info:\n");
224 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s",
225 1.13 mrg "Attr Hits", "Misses", "Lkup Hits", "Misses");
226 1.13 mrg printf(" %9.9s %9.9s %9.9s %9.9s\n",
227 1.13 mrg "BioR Hits", "Misses", "BioW Hits", "Misses");
228 1.13 mrg printf("%9d %9d %9d %9d",
229 1.13 mrg nfsstats.attrcache_hits, nfsstats.attrcache_misses,
230 1.13 mrg nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
231 1.13 mrg printf(" %9d %9d %9d %9d\n",
232 1.13 mrg nfsstats.biocache_reads-nfsstats.read_bios,
233 1.13 mrg nfsstats.read_bios,
234 1.13 mrg nfsstats.biocache_writes-nfsstats.write_bios,
235 1.13 mrg nfsstats.write_bios);
236 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s",
237 1.13 mrg "BioRLHits", "Misses", "BioD Hits", "Misses");
238 1.13 mrg printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
239 1.13 mrg printf("%9d %9d %9d %9d",
240 1.13 mrg nfsstats.biocache_readlinks-nfsstats.readlink_bios,
241 1.13 mrg nfsstats.readlink_bios,
242 1.13 mrg nfsstats.biocache_readdirs-nfsstats.readdir_bios,
243 1.13 mrg nfsstats.readdir_bios);
244 1.13 mrg printf(" %9d %9d\n",
245 1.13 mrg nfsstats.direofcache_hits, nfsstats.direofcache_misses);
246 1.10 hubertf }
247 1.10 hubertf if (printall || (clientinfo && serverinfo)){
248 1.13 mrg printf("\n");
249 1.10 hubertf }
250 1.10 hubertf if (printall || serverinfo){
251 1.13 mrg printf("Server Info:\n");
252 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
253 1.13 mrg "Getattr", "Setattr", "Lookup", "Readlink", "Read",
254 1.13 mrg "Write", "Create", "Remove");
255 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
256 1.13 mrg nfsstats.srvrpccnt[NFSPROC_GETATTR],
257 1.13 mrg nfsstats.srvrpccnt[NFSPROC_SETATTR],
258 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LOOKUP],
259 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READLINK],
260 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READ],
261 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE],
262 1.13 mrg nfsstats.srvrpccnt[NFSPROC_CREATE],
263 1.13 mrg nfsstats.srvrpccnt[NFSPROC_REMOVE]);
264 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
265 1.13 mrg "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
266 1.13 mrg "Readdir", "RdirPlus", "Access");
267 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
268 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RENAME],
269 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LINK],
270 1.13 mrg nfsstats.srvrpccnt[NFSPROC_SYMLINK],
271 1.13 mrg nfsstats.srvrpccnt[NFSPROC_MKDIR],
272 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RMDIR],
273 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READDIR],
274 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READDIRPLUS],
275 1.13 mrg nfsstats.srvrpccnt[NFSPROC_ACCESS]);
276 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
277 1.13 mrg "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
278 1.13 mrg "GLease", "Vacate", "Evict");
279 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
280 1.13 mrg nfsstats.srvrpccnt[NFSPROC_MKNOD],
281 1.13 mrg nfsstats.srvrpccnt[NFSPROC_FSSTAT],
282 1.13 mrg nfsstats.srvrpccnt[NFSPROC_FSINFO],
283 1.13 mrg nfsstats.srvrpccnt[NFSPROC_PATHCONF],
284 1.13 mrg nfsstats.srvrpccnt[NFSPROC_COMMIT],
285 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_GETLEASE],
286 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_VACATED],
287 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_EVICTED]);
288 1.13 mrg printf("Server Ret-Failed\n");
289 1.13 mrg printf("%17d\n", nfsstats.srvrpc_errs);
290 1.13 mrg printf("Server Faults\n");
291 1.13 mrg printf("%13d\n", nfsstats.srv_errs);
292 1.13 mrg printf("Server Cache Stats:\n");
293 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s\n",
294 1.13 mrg "Inprog", "Idem", "Non-idem", "Misses");
295 1.13 mrg printf("%9d %9d %9d %9d\n",
296 1.13 mrg nfsstats.srvcache_inproghits,
297 1.13 mrg nfsstats.srvcache_idemdonehits,
298 1.13 mrg nfsstats.srvcache_nonidemdonehits,
299 1.13 mrg nfsstats.srvcache_misses);
300 1.13 mrg printf("Server Lease Stats:\n");
301 1.13 mrg printf("%9.9s %9.9s %9.9s\n",
302 1.13 mrg "Leases", "PeakL", "GLeases");
303 1.13 mrg printf("%9d %9d %9d\n",
304 1.13 mrg nfsstats.srvnqnfs_leases,
305 1.13 mrg nfsstats.srvnqnfs_maxleases,
306 1.13 mrg nfsstats.srvnqnfs_getleases);
307 1.13 mrg printf("Server Write Gathering:\n");
308 1.13 mrg printf("%9.9s %9.9s %9.9s\n",
309 1.13 mrg "WriteOps", "WriteRPC", "Opsaved");
310 1.13 mrg printf("%9d %9d %9d\n",
311 1.13 mrg nfsstats.srvvop_writes,
312 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE],
313 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE] - nfsstats.srvvop_writes);
314 1.10 hubertf }
315 1.1 cgd }
316 1.1 cgd
317 1.1 cgd u_char signalled; /* set if alarm goes off "early" */
318 1.1 cgd
319 1.1 cgd /*
320 1.1 cgd * Print a running summary of nfs statistics.
321 1.1 cgd * Repeat display every interval seconds, showing statistics
322 1.1 cgd * collected over that interval. Assumes that interval is non-zero.
323 1.1 cgd * First line printed at top of screen is always cumulative.
324 1.1 cgd */
325 1.1 cgd void
326 1.1 cgd sidewaysintpr(interval, off)
327 1.1 cgd u_int interval;
328 1.5 mycroft u_long off;
329 1.1 cgd {
330 1.1 cgd struct nfsstats nfsstats, lastst;
331 1.1 cgd int hdrcnt, oldmask;
332 1.1 cgd
333 1.1 cgd (void)signal(SIGALRM, catchalarm);
334 1.1 cgd signalled = 0;
335 1.1 cgd (void)alarm(interval);
336 1.9 lukem memset((caddr_t)&lastst, 0, sizeof(lastst));
337 1.1 cgd
338 1.1 cgd for (hdrcnt = 1;;) {
339 1.1 cgd if (!--hdrcnt) {
340 1.1 cgd printhdr();
341 1.1 cgd hdrcnt = 20;
342 1.1 cgd }
343 1.12 msaitoh if (kvm_read(kd, off, (char *)&nfsstats, sizeof(nfsstats))
344 1.12 msaitoh != sizeof(nfsstats))
345 1.9 lukem errx(1, "kvm_read failed");
346 1.10 hubertf if (printall || clientinfo)
347 1.13 mrg printf("Client: %8d %8d %8d %8d %8d %8d %8d %8d\n",
348 1.13 mrg nfsstats.rpccnt[NFSPROC_GETATTR] -
349 1.13 mrg lastst.rpccnt[NFSPROC_GETATTR],
350 1.13 mrg nfsstats.rpccnt[NFSPROC_LOOKUP] -
351 1.13 mrg lastst.rpccnt[NFSPROC_LOOKUP],
352 1.13 mrg nfsstats.rpccnt[NFSPROC_READLINK] -
353 1.13 mrg lastst.rpccnt[NFSPROC_READLINK],
354 1.13 mrg nfsstats.rpccnt[NFSPROC_READ] -
355 1.13 mrg lastst.rpccnt[NFSPROC_READ],
356 1.13 mrg nfsstats.rpccnt[NFSPROC_WRITE] -
357 1.13 mrg lastst.rpccnt[NFSPROC_WRITE],
358 1.13 mrg nfsstats.rpccnt[NFSPROC_RENAME] -
359 1.13 mrg lastst.rpccnt[NFSPROC_RENAME],
360 1.13 mrg nfsstats.rpccnt[NFSPROC_ACCESS] -
361 1.13 mrg lastst.rpccnt[NFSPROC_ACCESS],
362 1.13 mrg (nfsstats.rpccnt[NFSPROC_READDIR] -
363 1.13 mrg lastst.rpccnt[NFSPROC_READDIR]) +
364 1.13 mrg (nfsstats.rpccnt[NFSPROC_READDIRPLUS] -
365 1.13 mrg lastst.rpccnt[NFSPROC_READDIRPLUS]));
366 1.10 hubertf if (printall || serverinfo)
367 1.13 mrg printf("Server: %8d %8d %8d %8d %8d %8d %8d %8d\n",
368 1.13 mrg nfsstats.srvrpccnt[NFSPROC_GETATTR] -
369 1.13 mrg lastst.srvrpccnt[NFSPROC_GETATTR],
370 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LOOKUP] -
371 1.13 mrg lastst.srvrpccnt[NFSPROC_LOOKUP],
372 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READLINK] -
373 1.13 mrg lastst.srvrpccnt[NFSPROC_READLINK],
374 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READ] -
375 1.13 mrg lastst.srvrpccnt[NFSPROC_READ],
376 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE] -
377 1.13 mrg lastst.srvrpccnt[NFSPROC_WRITE],
378 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RENAME] -
379 1.13 mrg lastst.srvrpccnt[NFSPROC_RENAME],
380 1.13 mrg nfsstats.srvrpccnt[NFSPROC_ACCESS] -
381 1.13 mrg lastst.srvrpccnt[NFSPROC_ACCESS],
382 1.13 mrg (nfsstats.srvrpccnt[NFSPROC_READDIR] -
383 1.13 mrg lastst.srvrpccnt[NFSPROC_READDIR]) +
384 1.13 mrg (nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] -
385 1.13 mrg lastst.srvrpccnt[NFSPROC_READDIRPLUS]));
386 1.1 cgd lastst = nfsstats;
387 1.1 cgd fflush(stdout);
388 1.1 cgd oldmask = sigblock(sigmask(SIGALRM));
389 1.1 cgd if (!signalled)
390 1.1 cgd sigpause(0);
391 1.1 cgd sigsetmask(oldmask);
392 1.1 cgd signalled = 0;
393 1.1 cgd (void)alarm(interval);
394 1.1 cgd }
395 1.1 cgd /*NOTREACHED*/
396 1.1 cgd }
397 1.1 cgd
398 1.1 cgd void
399 1.1 cgd printhdr()
400 1.1 cgd {
401 1.13 mrg
402 1.1 cgd printf(" %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s\n",
403 1.1 cgd "Getattr", "Lookup", "Readlink", "Read", "Write", "Rename",
404 1.6 fvdl "Access", "Readdir");
405 1.1 cgd fflush(stdout);
406 1.1 cgd }
407 1.1 cgd
408 1.1 cgd /*
409 1.1 cgd * Called if an interval expires before sidewaysintpr has completed a loop.
410 1.1 cgd * Sets a flag to not wait for the alarm.
411 1.1 cgd */
412 1.1 cgd void
413 1.9 lukem catchalarm(dummy)
414 1.9 lukem int dummy;
415 1.1 cgd {
416 1.13 mrg
417 1.1 cgd signalled = 1;
418 1.1 cgd }
419 1.1 cgd
420 1.1 cgd void
421 1.1 cgd usage()
422 1.1 cgd {
423 1.13 mrg
424 1.1 cgd (void)fprintf(stderr,
425 1.13 mrg "usage: nfsstat [-cs] [-M core] [-N system] [-w interval]\n");
426 1.1 cgd exit(1);
427 1.1 cgd }
428