[BACK]Return to nfsstat.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / nfsstat

Annotation of src/usr.bin/nfsstat/nfsstat.c, Revision 1.24

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