nfsstat.c revision 1.16 1 1.16 simonb /* $NetBSD: nfsstat.c,v 1.16 2000/06/13 12:39:43 simonb 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.16 simonb __RCSID("$NetBSD: nfsstat.c,v 1.16 2000/06/13 12:39:43 simonb 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.16 simonb
81 1.1 cgd
82 1.9 lukem void catchalarm __P((int));
83 1.16 simonb void getstats __P((struct nfsstats *));
84 1.16 simonb void intpr __P((void));
85 1.9 lukem int main __P((int, char **));
86 1.9 lukem void printhdr __P((void));
87 1.16 simonb void sidewaysintpr __P((u_int));
88 1.9 lukem void usage __P((void));
89 1.1 cgd
90 1.16 simonb kvm_t *kd;
91 1.10 hubertf int printall, clientinfo, serverinfo;
92 1.16 simonb u_long nfsstataddr;
93 1.10 hubertf
94 1.9 lukem int
95 1.1 cgd main(argc, argv)
96 1.1 cgd int argc;
97 1.1 cgd char **argv;
98 1.1 cgd {
99 1.1 cgd u_int interval;
100 1.1 cgd int ch;
101 1.5 mycroft char *memf, *nlistf;
102 1.8 explorer char errbuf[_POSIX2_LINE_MAX];
103 1.1 cgd
104 1.1 cgd interval = 0;
105 1.5 mycroft memf = nlistf = NULL;
106 1.10 hubertf printall = 1;
107 1.10 hubertf while ((ch = getopt(argc, argv, "M:N:w:cs")) != -1)
108 1.1 cgd switch(ch) {
109 1.1 cgd case 'M':
110 1.5 mycroft memf = optarg;
111 1.1 cgd break;
112 1.1 cgd case 'N':
113 1.5 mycroft nlistf = optarg;
114 1.1 cgd break;
115 1.1 cgd case 'w':
116 1.1 cgd interval = atoi(optarg);
117 1.1 cgd break;
118 1.10 hubertf case 's':
119 1.10 hubertf serverinfo = 1;
120 1.10 hubertf printall = 0;
121 1.10 hubertf break;
122 1.10 hubertf case 'c':
123 1.10 hubertf clientinfo = 1;
124 1.10 hubertf printall = 0;
125 1.10 hubertf break;
126 1.1 cgd case '?':
127 1.1 cgd default:
128 1.1 cgd usage();
129 1.1 cgd }
130 1.1 cgd argc -= optind;
131 1.1 cgd argv += optind;
132 1.1 cgd
133 1.1 cgd #define BACKWARD_COMPATIBILITY
134 1.1 cgd #ifdef BACKWARD_COMPATIBILITY
135 1.1 cgd if (*argv) {
136 1.5 mycroft interval = atoi(*argv);
137 1.1 cgd if (*++argv) {
138 1.5 mycroft nlistf = *argv;
139 1.5 mycroft if (*++argv)
140 1.5 mycroft memf = *argv;
141 1.1 cgd }
142 1.1 cgd }
143 1.1 cgd #endif
144 1.16 simonb if (nlistf || memf) {
145 1.16 simonb if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf))
146 1.16 simonb == 0)
147 1.16 simonb errx(1, "kvm_openfiles: %s", errbuf);
148 1.16 simonb
149 1.16 simonb if (kvm_nlist(kd, nl) != 0)
150 1.16 simonb errx(1, "kvm_nlist: can't get names");
151 1.16 simonb nfsstataddr = nl[N_NFSSTAT].n_value;
152 1.16 simonb } else {
153 1.16 simonb kd = NULL;
154 1.16 simonb }
155 1.1 cgd
156 1.1 cgd if (interval)
157 1.16 simonb sidewaysintpr(interval);
158 1.1 cgd else
159 1.16 simonb intpr();
160 1.1 cgd exit(0);
161 1.1 cgd }
162 1.1 cgd
163 1.16 simonb void
164 1.16 simonb getstats(ns)
165 1.16 simonb struct nfsstats *ns;
166 1.16 simonb {
167 1.16 simonb size_t size;
168 1.16 simonb int mib[3];
169 1.16 simonb
170 1.16 simonb if (kd) {
171 1.16 simonb if (kvm_read(kd, (u_long)nfsstataddr, ns, sizeof(*ns))
172 1.16 simonb != sizeof(*ns))
173 1.16 simonb errx(1, "kvm_read failed");
174 1.16 simonb } else {
175 1.16 simonb mib[0] = CTL_VFS;
176 1.16 simonb mib[1] = 2; /* XXX from CTL_VFS_NAMES in <sys/mount.h> */
177 1.16 simonb mib[2] = NFS_NFSSTATS;
178 1.16 simonb
179 1.16 simonb size = sizeof(*ns);
180 1.16 simonb if (sysctl(mib, 3, ns, &size, NULL, 0) == -1)
181 1.16 simonb err(1, "sysctl(NFS_NFSSTATS) failed");
182 1.16 simonb }
183 1.16 simonb }
184 1.16 simonb
185 1.1 cgd /*
186 1.5 mycroft * Print a description of the nfs stats.
187 1.1 cgd */
188 1.1 cgd void
189 1.16 simonb intpr()
190 1.1 cgd {
191 1.1 cgd struct nfsstats nfsstats;
192 1.1 cgd
193 1.16 simonb getstats(&nfsstats);
194 1.13 mrg if (printall || clientinfo) {
195 1.13 mrg printf("Client Info:\n");
196 1.13 mrg printf("Rpc Counts:\n");
197 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
198 1.13 mrg "Getattr", "Setattr", "Lookup", "Readlink", "Read",
199 1.13 mrg "Write", "Create", "Remove");
200 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
201 1.13 mrg nfsstats.rpccnt[NFSPROC_GETATTR],
202 1.13 mrg nfsstats.rpccnt[NFSPROC_SETATTR],
203 1.13 mrg nfsstats.rpccnt[NFSPROC_LOOKUP],
204 1.13 mrg nfsstats.rpccnt[NFSPROC_READLINK],
205 1.13 mrg nfsstats.rpccnt[NFSPROC_READ],
206 1.13 mrg nfsstats.rpccnt[NFSPROC_WRITE],
207 1.13 mrg nfsstats.rpccnt[NFSPROC_CREATE],
208 1.13 mrg nfsstats.rpccnt[NFSPROC_REMOVE]);
209 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
210 1.13 mrg "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
211 1.13 mrg "Readdir", "RdirPlus", "Access");
212 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
213 1.13 mrg nfsstats.rpccnt[NFSPROC_RENAME],
214 1.13 mrg nfsstats.rpccnt[NFSPROC_LINK],
215 1.13 mrg nfsstats.rpccnt[NFSPROC_SYMLINK],
216 1.13 mrg nfsstats.rpccnt[NFSPROC_MKDIR],
217 1.13 mrg nfsstats.rpccnt[NFSPROC_RMDIR],
218 1.13 mrg nfsstats.rpccnt[NFSPROC_READDIR],
219 1.13 mrg nfsstats.rpccnt[NFSPROC_READDIRPLUS],
220 1.13 mrg nfsstats.rpccnt[NFSPROC_ACCESS]);
221 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
222 1.13 mrg "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
223 1.13 mrg "GLease", "Vacate", "Evict");
224 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
225 1.13 mrg nfsstats.rpccnt[NFSPROC_MKNOD],
226 1.13 mrg nfsstats.rpccnt[NFSPROC_FSSTAT],
227 1.13 mrg nfsstats.rpccnt[NFSPROC_FSINFO],
228 1.13 mrg nfsstats.rpccnt[NFSPROC_PATHCONF],
229 1.13 mrg nfsstats.rpccnt[NFSPROC_COMMIT],
230 1.13 mrg nfsstats.rpccnt[NQNFSPROC_GETLEASE],
231 1.13 mrg nfsstats.rpccnt[NQNFSPROC_VACATED],
232 1.13 mrg nfsstats.rpccnt[NQNFSPROC_EVICTED]);
233 1.13 mrg printf("Rpc Info:\n");
234 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
235 1.13 mrg "TimedOut", "Invalid", "X Replies", "Retries", "Requests");
236 1.13 mrg printf("%9d %9d %9d %9d %9d\n",
237 1.13 mrg nfsstats.rpctimeouts,
238 1.13 mrg nfsstats.rpcinvalid,
239 1.13 mrg nfsstats.rpcunexpected,
240 1.13 mrg nfsstats.rpcretries,
241 1.13 mrg nfsstats.rpcrequests);
242 1.13 mrg printf("Cache Info:\n");
243 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s",
244 1.13 mrg "Attr Hits", "Misses", "Lkup Hits", "Misses");
245 1.13 mrg printf(" %9.9s %9.9s %9.9s %9.9s\n",
246 1.13 mrg "BioR Hits", "Misses", "BioW Hits", "Misses");
247 1.13 mrg printf("%9d %9d %9d %9d",
248 1.13 mrg nfsstats.attrcache_hits, nfsstats.attrcache_misses,
249 1.13 mrg nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
250 1.13 mrg printf(" %9d %9d %9d %9d\n",
251 1.13 mrg nfsstats.biocache_reads-nfsstats.read_bios,
252 1.13 mrg nfsstats.read_bios,
253 1.13 mrg nfsstats.biocache_writes-nfsstats.write_bios,
254 1.13 mrg nfsstats.write_bios);
255 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s",
256 1.13 mrg "BioRLHits", "Misses", "BioD Hits", "Misses");
257 1.13 mrg printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
258 1.13 mrg printf("%9d %9d %9d %9d",
259 1.13 mrg nfsstats.biocache_readlinks-nfsstats.readlink_bios,
260 1.13 mrg nfsstats.readlink_bios,
261 1.13 mrg nfsstats.biocache_readdirs-nfsstats.readdir_bios,
262 1.13 mrg nfsstats.readdir_bios);
263 1.13 mrg printf(" %9d %9d\n",
264 1.13 mrg nfsstats.direofcache_hits, nfsstats.direofcache_misses);
265 1.10 hubertf }
266 1.10 hubertf if (printall || (clientinfo && serverinfo)){
267 1.13 mrg printf("\n");
268 1.10 hubertf }
269 1.10 hubertf if (printall || serverinfo){
270 1.13 mrg printf("Server Info:\n");
271 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
272 1.13 mrg "Getattr", "Setattr", "Lookup", "Readlink", "Read",
273 1.13 mrg "Write", "Create", "Remove");
274 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
275 1.13 mrg nfsstats.srvrpccnt[NFSPROC_GETATTR],
276 1.13 mrg nfsstats.srvrpccnt[NFSPROC_SETATTR],
277 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LOOKUP],
278 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READLINK],
279 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READ],
280 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE],
281 1.13 mrg nfsstats.srvrpccnt[NFSPROC_CREATE],
282 1.13 mrg nfsstats.srvrpccnt[NFSPROC_REMOVE]);
283 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
284 1.13 mrg "Rename", "Link", "Symlink", "Mkdir", "Rmdir",
285 1.13 mrg "Readdir", "RdirPlus", "Access");
286 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
287 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RENAME],
288 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LINK],
289 1.13 mrg nfsstats.srvrpccnt[NFSPROC_SYMLINK],
290 1.13 mrg nfsstats.srvrpccnt[NFSPROC_MKDIR],
291 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RMDIR],
292 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READDIR],
293 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READDIRPLUS],
294 1.13 mrg nfsstats.srvrpccnt[NFSPROC_ACCESS]);
295 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
296 1.13 mrg "Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit",
297 1.13 mrg "GLease", "Vacate", "Evict");
298 1.13 mrg printf("%9d %9d %9d %9d %9d %9d %9d %9d\n",
299 1.13 mrg nfsstats.srvrpccnt[NFSPROC_MKNOD],
300 1.13 mrg nfsstats.srvrpccnt[NFSPROC_FSSTAT],
301 1.13 mrg nfsstats.srvrpccnt[NFSPROC_FSINFO],
302 1.13 mrg nfsstats.srvrpccnt[NFSPROC_PATHCONF],
303 1.13 mrg nfsstats.srvrpccnt[NFSPROC_COMMIT],
304 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_GETLEASE],
305 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_VACATED],
306 1.13 mrg nfsstats.srvrpccnt[NQNFSPROC_EVICTED]);
307 1.13 mrg printf("Server Ret-Failed\n");
308 1.13 mrg printf("%17d\n", nfsstats.srvrpc_errs);
309 1.13 mrg printf("Server Faults\n");
310 1.13 mrg printf("%13d\n", nfsstats.srv_errs);
311 1.13 mrg printf("Server Cache Stats:\n");
312 1.13 mrg printf("%9.9s %9.9s %9.9s %9.9s\n",
313 1.13 mrg "Inprog", "Idem", "Non-idem", "Misses");
314 1.13 mrg printf("%9d %9d %9d %9d\n",
315 1.13 mrg nfsstats.srvcache_inproghits,
316 1.13 mrg nfsstats.srvcache_idemdonehits,
317 1.13 mrg nfsstats.srvcache_nonidemdonehits,
318 1.13 mrg nfsstats.srvcache_misses);
319 1.13 mrg printf("Server Lease Stats:\n");
320 1.13 mrg printf("%9.9s %9.9s %9.9s\n",
321 1.13 mrg "Leases", "PeakL", "GLeases");
322 1.13 mrg printf("%9d %9d %9d\n",
323 1.13 mrg nfsstats.srvnqnfs_leases,
324 1.13 mrg nfsstats.srvnqnfs_maxleases,
325 1.13 mrg nfsstats.srvnqnfs_getleases);
326 1.13 mrg printf("Server Write Gathering:\n");
327 1.13 mrg printf("%9.9s %9.9s %9.9s\n",
328 1.13 mrg "WriteOps", "WriteRPC", "Opsaved");
329 1.13 mrg printf("%9d %9d %9d\n",
330 1.13 mrg nfsstats.srvvop_writes,
331 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE],
332 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE] - nfsstats.srvvop_writes);
333 1.10 hubertf }
334 1.1 cgd }
335 1.1 cgd
336 1.1 cgd u_char signalled; /* set if alarm goes off "early" */
337 1.1 cgd
338 1.1 cgd /*
339 1.1 cgd * Print a running summary of nfs statistics.
340 1.1 cgd * Repeat display every interval seconds, showing statistics
341 1.1 cgd * collected over that interval. Assumes that interval is non-zero.
342 1.1 cgd * First line printed at top of screen is always cumulative.
343 1.1 cgd */
344 1.1 cgd void
345 1.16 simonb sidewaysintpr(interval)
346 1.1 cgd u_int interval;
347 1.1 cgd {
348 1.1 cgd struct nfsstats nfsstats, lastst;
349 1.1 cgd int hdrcnt, oldmask;
350 1.1 cgd
351 1.1 cgd (void)signal(SIGALRM, catchalarm);
352 1.1 cgd signalled = 0;
353 1.1 cgd (void)alarm(interval);
354 1.9 lukem memset((caddr_t)&lastst, 0, sizeof(lastst));
355 1.1 cgd
356 1.1 cgd for (hdrcnt = 1;;) {
357 1.1 cgd if (!--hdrcnt) {
358 1.1 cgd printhdr();
359 1.1 cgd hdrcnt = 20;
360 1.1 cgd }
361 1.16 simonb getstats(&nfsstats);
362 1.10 hubertf if (printall || clientinfo)
363 1.13 mrg printf("Client: %8d %8d %8d %8d %8d %8d %8d %8d\n",
364 1.13 mrg nfsstats.rpccnt[NFSPROC_GETATTR] -
365 1.13 mrg lastst.rpccnt[NFSPROC_GETATTR],
366 1.13 mrg nfsstats.rpccnt[NFSPROC_LOOKUP] -
367 1.13 mrg lastst.rpccnt[NFSPROC_LOOKUP],
368 1.13 mrg nfsstats.rpccnt[NFSPROC_READLINK] -
369 1.13 mrg lastst.rpccnt[NFSPROC_READLINK],
370 1.13 mrg nfsstats.rpccnt[NFSPROC_READ] -
371 1.13 mrg lastst.rpccnt[NFSPROC_READ],
372 1.13 mrg nfsstats.rpccnt[NFSPROC_WRITE] -
373 1.13 mrg lastst.rpccnt[NFSPROC_WRITE],
374 1.13 mrg nfsstats.rpccnt[NFSPROC_RENAME] -
375 1.13 mrg lastst.rpccnt[NFSPROC_RENAME],
376 1.13 mrg nfsstats.rpccnt[NFSPROC_ACCESS] -
377 1.13 mrg lastst.rpccnt[NFSPROC_ACCESS],
378 1.13 mrg (nfsstats.rpccnt[NFSPROC_READDIR] -
379 1.13 mrg lastst.rpccnt[NFSPROC_READDIR]) +
380 1.13 mrg (nfsstats.rpccnt[NFSPROC_READDIRPLUS] -
381 1.13 mrg lastst.rpccnt[NFSPROC_READDIRPLUS]));
382 1.10 hubertf if (printall || serverinfo)
383 1.13 mrg printf("Server: %8d %8d %8d %8d %8d %8d %8d %8d\n",
384 1.13 mrg nfsstats.srvrpccnt[NFSPROC_GETATTR] -
385 1.13 mrg lastst.srvrpccnt[NFSPROC_GETATTR],
386 1.13 mrg nfsstats.srvrpccnt[NFSPROC_LOOKUP] -
387 1.13 mrg lastst.srvrpccnt[NFSPROC_LOOKUP],
388 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READLINK] -
389 1.13 mrg lastst.srvrpccnt[NFSPROC_READLINK],
390 1.13 mrg nfsstats.srvrpccnt[NFSPROC_READ] -
391 1.13 mrg lastst.srvrpccnt[NFSPROC_READ],
392 1.13 mrg nfsstats.srvrpccnt[NFSPROC_WRITE] -
393 1.13 mrg lastst.srvrpccnt[NFSPROC_WRITE],
394 1.13 mrg nfsstats.srvrpccnt[NFSPROC_RENAME] -
395 1.13 mrg lastst.srvrpccnt[NFSPROC_RENAME],
396 1.13 mrg nfsstats.srvrpccnt[NFSPROC_ACCESS] -
397 1.13 mrg lastst.srvrpccnt[NFSPROC_ACCESS],
398 1.13 mrg (nfsstats.srvrpccnt[NFSPROC_READDIR] -
399 1.13 mrg lastst.srvrpccnt[NFSPROC_READDIR]) +
400 1.13 mrg (nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] -
401 1.13 mrg lastst.srvrpccnt[NFSPROC_READDIRPLUS]));
402 1.1 cgd lastst = nfsstats;
403 1.1 cgd fflush(stdout);
404 1.1 cgd oldmask = sigblock(sigmask(SIGALRM));
405 1.1 cgd if (!signalled)
406 1.1 cgd sigpause(0);
407 1.1 cgd sigsetmask(oldmask);
408 1.1 cgd signalled = 0;
409 1.1 cgd (void)alarm(interval);
410 1.1 cgd }
411 1.1 cgd /*NOTREACHED*/
412 1.1 cgd }
413 1.1 cgd
414 1.1 cgd void
415 1.1 cgd printhdr()
416 1.1 cgd {
417 1.13 mrg
418 1.1 cgd printf(" %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s\n",
419 1.1 cgd "Getattr", "Lookup", "Readlink", "Read", "Write", "Rename",
420 1.6 fvdl "Access", "Readdir");
421 1.1 cgd fflush(stdout);
422 1.1 cgd }
423 1.1 cgd
424 1.1 cgd /*
425 1.1 cgd * Called if an interval expires before sidewaysintpr has completed a loop.
426 1.1 cgd * Sets a flag to not wait for the alarm.
427 1.1 cgd */
428 1.1 cgd void
429 1.9 lukem catchalarm(dummy)
430 1.9 lukem int dummy;
431 1.1 cgd {
432 1.13 mrg
433 1.1 cgd signalled = 1;
434 1.1 cgd }
435 1.1 cgd
436 1.1 cgd void
437 1.1 cgd usage()
438 1.1 cgd {
439 1.13 mrg
440 1.1 cgd (void)fprintf(stderr,
441 1.13 mrg "usage: nfsstat [-cs] [-M core] [-N system] [-w interval]\n");
442 1.1 cgd exit(1);
443 1.1 cgd }
444