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