[BACK]Return to vmstat.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / systat

Annotation of src/usr.bin/systat/vmstat.c, Revision 1.82.4.2

1.82.4.2! pgoyette    1: /*     $NetBSD: vmstat.c,v 1.82.4.1 2018/12/26 14:02:11 pgoyette Exp $ */
1.2       jtc         2:
1.1       jtc         3: /*-
                      4:  * Copyright (c) 1983, 1989, 1992, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
1.53      agc        15:  * 3. Neither the name of the University nor the names of its contributors
1.1       jtc        16:  *    may be used to endorse or promote products derived from this software
                     17:  *    without specific prior written permission.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  */
                     31:
1.8       mrg        32: #include <sys/cdefs.h>
1.1       jtc        33: #ifndef lint
1.2       jtc        34: #if 0
1.1       jtc        35: static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 1/12/94";
1.2       jtc        36: #endif
1.82.4.2! pgoyette   37: __RCSID("$NetBSD: vmstat.c,v 1.82.4.1 2018/12/26 14:02:11 pgoyette Exp $");
1.1       jtc        38: #endif /* not lint */
                     39:
                     40: /*
                     41:  * Cursed vmstat -- from Robert Elz.
                     42:  */
                     43:
                     44: #include <sys/param.h>
1.67      christos   45: #include <sys/uio.h>
1.1       jtc        46: #include <sys/namei.h>
                     47: #include <sys/sysctl.h>
1.70      dyoung     48: #include <sys/evcnt.h>
1.1       jtc        49:
1.11      mrg        50: #include <uvm/uvm_extern.h>
                     51:
1.66      yamt       52: #include <errno.h>
1.3       mycroft    53: #include <stdlib.h>
1.1       jtc        54: #include <string.h>
1.41      abs        55: #include <util.h>
1.3       mycroft    56:
1.1       jtc        57: #include "systat.h"
                     58: #include "extern.h"
1.65      blymn      59: #include "drvstats.h"
1.40      christos   60: #include "utmpentry.h"
1.63      dsl        61: #include "vmstat.h"
1.1       jtc        62:
                     63: static struct Info {
1.34      simonb     64:        struct  uvmexp_sysctl uvmexp;
1.1       jtc        65:        struct  vmtotal Total;
1.81      dennis     66:        struct  nchstats nchstats;
1.1       jtc        67:        long    nchcount;
                     68:        long    *intrcnt;
1.44      dsl        69:        u_int64_t       *evcnt;
1.1       jtc        70: } s, s1, s2, z;
                     71:
1.63      dsl        72: enum display_mode display_mode = TIME;
1.1       jtc        73:
1.33      ad         74: static void allocinfo(struct Info *);
                     75: static void copyinfo(struct Info *, struct Info *);
                     76: static float cputime(int);
1.49      dsl        77: static void dinfo(int, int, int);
1.63      dsl        78: static void getinfo(struct Info *);
1.33      ad         79: static int ucount(void);
1.1       jtc        80:
                     81: static char buf[26];
1.59      dsl        82: static u_int64_t temp;
1.63      dsl        83: double etime;
1.1       jtc        84: static float hertz;
                     85: static int nintr;
                     86: static long *intrloc;
                     87: static char **intrname;
                     88: static int nextintsrow;
1.49      dsl        89: static int disk_horiz = 1;
1.82.4.1  pgoyette   90: static u_int nbuf;
1.1       jtc        91:
                     92: WINDOW *
1.33      ad         93: openvmstat(void)
1.1       jtc        94: {
                     95:        return (stdscr);
                     96: }
                     97:
                     98: void
1.33      ad         99: closevmstat(WINDOW *w)
1.1       jtc       100: {
                    101:
                    102:        if (w == NULL)
                    103:                return;
                    104:        wclear(w);
                    105:        wrefresh(w);
                    106: }
                    107:
                    108:
                    109: static struct nlist namelist[] = {
1.79      joerg     110: #define        X_INTRNAMES     0
1.69      christos  111:        { .n_name = "_intrnames" },
1.79      joerg     112: #define        X_EINTRNAMES    1
1.69      christos  113:        { .n_name = "_eintrnames" },
1.79      joerg     114: #define        X_INTRCNT       2
1.69      christos  115:        { .n_name = "_intrcnt" },
1.79      joerg     116: #define        X_EINTRCNT      3
1.69      christos  117:        { .n_name = "_eintrcnt" },
1.79      joerg     118: #define        X_ALLEVENTS     4
1.69      christos  119:        { .n_name = "_allevents" },
                    120:        { .n_name = NULL }
1.1       jtc       121: };
                    122:
                    123: /*
                    124:  * These constants define where the major pieces are laid out
                    125:  */
                    126: #define STATROW                 0      /* uses 1 row and 68 cols */
                    127: #define STATCOL                 2
1.82.4.1  pgoyette  128: #define MEMROW          9      /* uses 5 rows and 31 cols */
1.1       jtc       129: #define MEMCOL          0
                    130: #define PAGEROW                 2      /* uses 4 rows and 26 cols */
1.48      dsl       131: #define PAGECOL                54
                    132: #define INTSROW                 9      /* uses all rows to bottom and 17 cols */
                    133: #define INTSCOL                40
                    134: #define INTSCOLEND     (VMSTATCOL - 0)
                    135: #define PROCSROW        2      /* uses 2 rows and 20 cols */
1.1       jtc       136: #define PROCSCOL        0
1.48      dsl       137: #define GENSTATROW      2      /* uses 2 rows and 30 cols */
1.58      christos  138: #define GENSTATCOL     17
1.48      dsl       139: #define VMSTATROW       7      /* uses 17 rows and 15 cols */
                    140: #define VMSTATCOL      64
                    141: #define GRAPHROW        5      /* uses 3 rows and 51 cols */
1.1       jtc       142: #define GRAPHCOL        0
1.82.4.1  pgoyette  143: #define NAMEIROW       15      /* uses 3 rows and 38 cols (must be MEMROW + 5 + 1) */
1.1       jtc       144: #define NAMEICOL        0
1.82.4.1  pgoyette  145: #define DISKROW                19      /* uses 5 rows and 50 cols (for 9 drives) */
1.1       jtc       146: #define DISKCOL                 0
1.82.4.1  pgoyette  147: #define DISKCOLWIDTH    8
1.49      dsl       148: #define DISKCOLEND     INTSCOL
1.1       jtc       149:
1.44      dsl       150: typedef struct intr_evcnt intr_evcnt_t;
                    151: struct intr_evcnt {
                    152:        char            *ie_group;
                    153:        char            *ie_name;
                    154:        u_int64_t       *ie_count;      /* kernel address... */
                    155:        int             ie_loc;         /* screen row */
                    156: } *ie_head;
                    157: int nevcnt;
                    158:
                    159: static void
                    160: get_interrupt_events(void)
                    161: {
                    162:        struct evcntlist allevents;
                    163:        struct evcnt evcnt, *evptr;
                    164:        intr_evcnt_t *ie;
1.55      itojun    165:        intr_evcnt_t *n;
1.44      dsl       166:
                    167:        if (!NREAD(X_ALLEVENTS, &allevents, sizeof allevents))
                    168:                return;
1.60      chs       169:        evptr = TAILQ_FIRST(&allevents);
                    170:        for (; evptr != NULL; evptr = TAILQ_NEXT(&evcnt, ev_list)) {
1.44      dsl       171:                if (!KREAD(evptr, &evcnt, sizeof evcnt))
                    172:                        return;
                    173:                if (evcnt.ev_type != EVCNT_TYPE_INTR)
                    174:                        continue;
1.55      itojun    175:                n = realloc(ie_head, sizeof *ie * (nevcnt + 1));
                    176:                if (n == NULL) {
1.44      dsl       177:                        error("realloc failed");
                    178:                        die(0);
                    179:                }
1.55      itojun    180:                ie_head = n;
1.44      dsl       181:                ie = ie_head + nevcnt;
                    182:                ie->ie_group = malloc(evcnt.ev_grouplen + 1);
                    183:                ie->ie_name = malloc(evcnt.ev_namelen + 1);
                    184:                if (ie->ie_group == NULL || ie->ie_name == NULL)
                    185:                        return;
1.46      dsl       186:                if (!KREAD(evcnt.ev_group, ie->ie_group, evcnt.ev_grouplen + 1))
1.44      dsl       187:                        return;
1.46      dsl       188:                if (!KREAD(evcnt.ev_name, ie->ie_name, evcnt.ev_namelen + 1))
1.44      dsl       189:                        return;
                    190:                ie->ie_count = &evptr->ev_count;
                    191:                ie->ie_loc = 0;
                    192:                nevcnt++;
                    193:        }
                    194: }
                    195:
1.1       jtc       196: int
1.33      ad        197: initvmstat(void)
1.1       jtc       198: {
1.64      dsl       199:        static char *intrnamebuf;
                    200:        char *cp;
1.1       jtc       201:        int i;
                    202:
1.64      dsl       203:        if (intrnamebuf)
                    204:                free(intrnamebuf);
                    205:        if (intrname)
                    206:                free(intrname);
                    207:        if (intrloc)
                    208:                free(intrloc);
                    209:
1.1       jtc       210:        if (namelist[0].n_type == 0) {
1.60      chs       211:                if (kvm_nlist(kd, namelist) &&
1.79      joerg     212:                    namelist[X_ALLEVENTS].n_type == 0) {
1.1       jtc       213:                        nlisterr(namelist);
                    214:                        return(0);
                    215:                }
                    216:        }
                    217:        hertz = stathz ? stathz : hz;
1.65      blymn     218:        if (!drvinit(1))
1.61      blymn     219:                return(0);
1.44      dsl       220:
                    221:        /* Old style interrupt counts - deprecated */
                    222:        nintr = (namelist[X_EINTRCNT].n_value -
                    223:                namelist[X_INTRCNT].n_value) / sizeof (long);
1.60      chs       224:        if (nintr) {
                    225:                intrloc = calloc(nintr, sizeof (long));
                    226:                intrname = calloc(nintr, sizeof (long));
                    227:                intrnamebuf = malloc(namelist[X_EINTRNAMES].n_value -
                    228:                                     namelist[X_INTRNAMES].n_value);
                    229:                if (intrnamebuf == NULL || intrname == 0 || intrloc == 0) {
                    230:                        error("Out of memory\n");
                    231:                        nintr = 0;
                    232:                        return(0);
                    233:                }
                    234:                NREAD(X_INTRNAMES, intrnamebuf, NVAL(X_EINTRNAMES) -
                    235:                      NVAL(X_INTRNAMES));
                    236:                for (cp = intrnamebuf, i = 0; i < nintr; i++) {
                    237:                        intrname[i] = cp;
                    238:                        cp += strlen(cp) + 1;
                    239:                }
1.44      dsl       240:        }
                    241:
                    242:        /* event counter interrupt counts */
                    243:        get_interrupt_events();
                    244:
1.48      dsl       245:        nextintsrow = INTSROW + 1;
1.44      dsl       246:        allocinfo(&s);
                    247:        allocinfo(&s1);
                    248:        allocinfo(&s2);
                    249:        allocinfo(&z);
                    250:
1.63      dsl       251:        getinfo(&s2);
1.1       jtc       252:        copyinfo(&s2, &s1);
                    253:        return(1);
                    254: }
                    255:
                    256: void
1.33      ad        257: fetchvmstat(void)
1.1       jtc       258: {
                    259:        time_t now;
                    260:
                    261:        time(&now);
1.50      itojun    262:        strlcpy(buf, ctime(&now), sizeof(buf));
1.18      marc      263:        buf[19] = '\0';
1.63      dsl       264:        getinfo(&s);
1.1       jtc       265: }
                    266:
1.44      dsl       267: static void
                    268: print_ie_title(int i)
                    269: {
                    270:        int width, name_width, group_width;
                    271:
1.48      dsl       272:        width = INTSCOLEND - (INTSCOL + 9);
1.44      dsl       273:        if (width <= 0)
                    274:                return;
                    275:
                    276:        move(ie_head[i].ie_loc, INTSCOL + 9);
                    277:        group_width = strlen(ie_head[i].ie_group);
                    278:        name_width = strlen(ie_head[i].ie_name);
                    279:        width -= group_width + 1 + name_width;
                    280:        if (width < 0) {
1.47      dsl       281:                /*
                    282:                 * Screen to narrow for full strings
                    283:                 * This is all rather horrid, in some cases there are a lot
                    284:                 * of events in the same group, and in others the event
                    285:                 * name is "intr".  There are also names which need 7 or 8
                    286:                 * columns before they become meaningful.
                    287:                 * This is a bad compromise.
                    288:                 */
1.44      dsl       289:                width = -width;
                    290:                group_width -= (width + 1) / 2;
                    291:                name_width -= width / 2;
1.47      dsl       292:                /* some have the 'useful' name "intr", display their group */
                    293:                if (strcasecmp(ie_head[i].ie_name, "intr") == 0) {
                    294:                         group_width += name_width + 1;
                    295:                         name_width = 0;
                    296:                } else {
                    297:                        if (group_width <= 3 || name_width < 0) {
                    298:                                /* don't display group */
                    299:                                name_width += group_width + 1;
                    300:                                group_width = 0;
                    301:                        }
1.44      dsl       302:                }
                    303:        }
                    304:
1.47      dsl       305:        if (group_width != 0) {
                    306:                printw("%-.*s", group_width, ie_head[i].ie_group);
                    307:                if (name_width != 0)
                    308:                        printw(" ");
                    309:        }
                    310:        if (name_width != 0)
                    311:                printw("%-.*s", name_width, ie_head[i].ie_name);
1.44      dsl       312: }
                    313:
1.1       jtc       314: void
1.63      dsl       315: labelvmstat_top(void)
1.1       jtc       316: {
                    317:
                    318:        clear();
1.63      dsl       319:
1.1       jtc       320:        mvprintw(STATROW, STATCOL + 4, "users    Load");
1.13      mrg       321:
1.82.4.1  pgoyette  322:        mvprintw(GENSTATROW, GENSTATCOL, "   Csw  Traps SysCal  Intr   Soft  Fault");
1.63      dsl       323:
                    324:        mvprintw(GRAPHROW, GRAPHCOL,
                    325:                "    . %% Sy    . %% Us    . %% Ni    . %% In    . %% Id");
1.75      rmind     326:        mvprintw(PROCSROW, PROCSCOL, "Proc:r  d  s");
1.63      dsl       327:        mvprintw(GRAPHROW + 1, GRAPHCOL,
                    328:                "|    |    |    |    |    |    |    |    |    |    |");
                    329:
                    330:        mvprintw(PAGEROW, PAGECOL + 8, "PAGING   SWAPPING ");
1.13      mrg       331:        mvprintw(PAGEROW + 1, PAGECOL, "        in  out   in  out ");
1.82.4.1  pgoyette  332:        mvprintw(PAGEROW + 2, PAGECOL, "  ops                     ");
                    333:        mvprintw(PAGEROW + 3, PAGECOL, "pages                     ");
1.63      dsl       334: }
                    335:
                    336: void
                    337: labelvmstat(void)
                    338: {
                    339:        int i;
1.1       jtc       340:
1.63      dsl       341:        /* Top few lines first */
1.1       jtc       342:
1.63      dsl       343:        labelvmstat_top();
1.1       jtc       344:
1.63      dsl       345:        /* Left hand column */
1.1       jtc       346:
1.82.4.1  pgoyette  347:        mvprintw(MEMROW + 0, MEMCOL, "Anon                 %%   zero         ");
                    348:        mvprintw(MEMROW + 1, MEMCOL, "Exec                 %%   wired        ");
                    349:        mvprintw(MEMROW + 2, MEMCOL, "File                 %%   inact        ");
                    350:        mvprintw(MEMROW + 3, MEMCOL, "Meta                 %%   bufs         ");
                    351:        mvprintw(MEMROW + 4, MEMCOL, " (kB)        real   swaponly      free");
                    352:        mvprintw(MEMROW + 5, MEMCOL, "Active                                ");
1.1       jtc       353:
                    354:        mvprintw(NAMEIROW, NAMEICOL, "Namei         Sys-cache     Proc-cache");
                    355:        mvprintw(NAMEIROW + 1, NAMEICOL,
                    356:                "    Calls     hits    %%     hits     %%");
1.63      dsl       357:
1.82.4.1  pgoyette  358:        mvprintw(DISKROW, DISKCOL, "%*s", DISKCOLWIDTH, "Disks:");
1.49      dsl       359:        if (disk_horiz) {
                    360:                mvprintw(DISKROW + 1, DISKCOL + 1, "seeks");
                    361:                mvprintw(DISKROW + 2, DISKCOL + 1, "xfers");
                    362:                mvprintw(DISKROW + 3, DISKCOL + 1, "bytes");
                    363:                mvprintw(DISKROW + 4, DISKCOL + 1, "%%busy");
                    364:        } else {
1.82.4.1  pgoyette  365:                mvprintw(DISKROW, DISKCOL + 1 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "seeks");
                    366:                mvprintw(DISKROW, DISKCOL + 2 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "xfers");
                    367:                mvprintw(DISKROW, DISKCOL + 3 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "bytes");
1.82.4.2! pgoyette  368:                mvprintw(DISKROW, DISKCOL + 4 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "%busy");
1.49      dsl       369:        }
1.63      dsl       370:
                    371:        /* Middle column */
                    372:
                    373:        mvprintw(INTSROW, INTSCOL + 9, "Interrupts");
1.1       jtc       374:        for (i = 0; i < nintr; i++) {
                    375:                if (intrloc[i] == 0)
                    376:                        continue;
1.47      dsl       377:                mvprintw(intrloc[i], INTSCOL + 9, "%-.*s",
1.48      dsl       378:                        INTSCOLEND - (INTSCOL + 9), intrname[i]);
1.1       jtc       379:        }
1.44      dsl       380:        for (i = 0; i < nevcnt; i++) {
                    381:                if (ie_head[i].ie_loc == 0)
                    382:                        continue;
                    383:                print_ie_title(i);
                    384:        }
1.63      dsl       385:
                    386:        /* Right hand column */
                    387:
                    388:        mvprintw(VMSTATROW + 0, VMSTATCOL + 10, "forks");
                    389:        mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw");
                    390:        mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "fksvm");
                    391:        mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "pwait");
                    392:        mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "relck");
                    393:        mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "rlkok");
                    394:        mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "noram");
                    395:        mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "ndcpy");
                    396:        mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "fltcp");
                    397:        mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "zfod");
                    398:        mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "cow");
                    399:        mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "fmin");
                    400:        mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "ftarg");
                    401:        mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "itarg");
1.82.4.1  pgoyette  402:        mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "flnan");
1.63      dsl       403:        mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "pdfre");
                    404:
                    405:        if (LINES - 1 > VMSTATROW + 16)
                    406:                mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "pdscn");
1.1       jtc       407: }
                    408:
1.63      dsl       409: #define X(s, s1, fld)  {temp = (s).fld[i]; (s).fld[i] -= (s1).fld[i]; \
                    410:                        if (display_mode == TIME) (s1).fld[i] = temp;}
                    411: #define Z(s, s1, fld)  {temp = (s).nchstats.fld; \
                    412:                        (s).nchstats.fld -= (s1).nchstats.fld; \
                    413:                        if (display_mode == TIME) (s1).nchstats.fld = temp;}
                    414: #define PUTRATE(s, s1, fld, l, c, w) \
                    415:                        {temp = (s).fld; (s).fld -= (s1).fld; \
                    416:                        if (display_mode == TIME) (s1).fld = temp; \
                    417:                        putint((int)((float)(s).fld/etime + 0.5), l, c, w);}
1.1       jtc       418: #define MAXFAIL 5
                    419:
1.25      simonb    420: static char cpuchar[CPUSTATES] = { '=' , '>', '-', '%', ' ' };
                    421: static char cpuorder[CPUSTATES] = { CP_SYS, CP_USER, CP_NICE, CP_INTR, CP_IDLE };
1.1       jtc       422:
                    423: void
1.63      dsl       424: show_vmstat_top(vmtotal_t *Total, uvmexp_sysctl_t *uvm, uvmexp_sysctl_t *uvm1)
                    425: {
                    426:        float f1, f2;
                    427:        int psiz;
                    428:        int i, l, c;
                    429:        struct {
                    430:                struct uvmexp_sysctl *uvmexp;
                    431:        } us, us1;
                    432:
                    433:        us.uvmexp = uvm;
                    434:        us1.uvmexp = uvm1;
                    435:
                    436:        putint(ucount(), STATROW, STATCOL, 3);
                    437:        putfloat(avenrun[0], STATROW, STATCOL + 17, 6, 2, 0);
                    438:        putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0);
                    439:        putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0);
                    440:        mvaddstr(STATROW, STATCOL + 53, buf);
                    441:
                    442:        putint(Total->t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3);
                    443:        putint(Total->t_dw, PROCSROW + 1, PROCSCOL + 6, 3);
                    444:        putint(Total->t_sl, PROCSROW + 1, PROCSCOL + 9, 3);
                    445:
                    446:        PUTRATE(us, us1, uvmexp->swtch, GENSTATROW + 1, GENSTATCOL - 1, 7);
1.68      dsl       447:        PUTRATE(us, us1, uvmexp->traps, GENSTATROW + 1, GENSTATCOL + 7, 6);
                    448:        PUTRATE(us, us1, uvmexp->syscalls, GENSTATROW + 1, GENSTATCOL + 14, 6);
                    449:        PUTRATE(us, us1, uvmexp->intrs, GENSTATROW + 1, GENSTATCOL + 21, 5);
1.72      njoly     450:        PUTRATE(us, us1, uvmexp->softs, GENSTATROW + 1, GENSTATCOL + 27, 6);
                    451:        PUTRATE(us, us1, uvmexp->faults, GENSTATROW + 1, GENSTATCOL + 34, 6);
1.63      dsl       452:
1.82.4.1  pgoyette  453:        /*
                    454:         * XXX it sure would be nice if this did what top(1) does and showed
                    455:         * the utilization of each CPU on a separate line, though perhaps IFF
                    456:         * the screen is tall enough
                    457:         */
1.63      dsl       458:        /* Last CPU state not calculated yet. */
                    459:        for (f2 = 0.0, psiz = 0, c = 0; c < CPUSTATES; c++) {
                    460:                i = cpuorder[c];
                    461:                f1 = cputime(i);
                    462:                f2 += f1;
                    463:                l = (int) ((f2 + 1.0) / 2.0) - psiz;
                    464:                if (c == 0)
                    465:                        putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0);
                    466:                else
                    467:                        putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0);
                    468:                mvhline(GRAPHROW + 2, psiz, cpuchar[c], l);
                    469:                psiz += l;
                    470:        }
                    471:
                    472:        PUTRATE(us, us1, uvmexp->pageins, PAGEROW + 2, PAGECOL + 5, 5);
                    473:        PUTRATE(us, us1, uvmexp->pdpageouts, PAGEROW + 2, PAGECOL + 10, 5);
                    474:        PUTRATE(us, us1, uvmexp->pgswapin, PAGEROW + 3, PAGECOL + 5, 5);
                    475:        PUTRATE(us, us1, uvmexp->pgswapout, PAGEROW + 3, PAGECOL + 10, 5);
                    476: }
                    477:
                    478: void
1.33      ad        479: showvmstat(void)
1.1       jtc       480: {
1.63      dsl       481:        int inttotal;
1.49      dsl       482:        int i, l, r, c;
1.1       jtc       483:        static int failcnt = 0;
1.49      dsl       484:        static int relabel = 0;
                    485:        static int last_disks = 0;
1.59      dsl       486:        static char pigs[] = "pigs";
1.82.4.1  pgoyette  487:        static u_long bufmem;
                    488:        struct buf_sysctl *buffers;
                    489:        int mib[6];
                    490:        size_t size;
                    491:        int extraslop = 0;
1.49      dsl       492:
                    493:        if (relabel) {
                    494:                labelvmstat();
                    495:                relabel = 0;
                    496:        }
1.39      sommerfe  497:
1.62      dsl       498:        cpuswap();
1.63      dsl       499:        if (display_mode == TIME) {
1.65      blymn     500:                drvswap();
1.44      dsl       501:                etime = cur.cp_etime;
                    502:                /* < 5 ticks - ignore this trash */
                    503:                if ((etime * hertz) < 1.0) {
1.74      wiz       504:                        if (failcnt++ <= MAXFAIL)
1.44      dsl       505:                                return;
1.1       jtc       506:                        clear();
                    507:                        mvprintw(2, 10, "The alternate system clock has died!");
                    508:                        mvprintw(3, 10, "Reverting to ``pigs'' display.");
                    509:                        move(CMDLINE, 0);
                    510:                        refresh();
                    511:                        failcnt = 0;
                    512:                        sleep(5);
1.59      dsl       513:                        command(pigs);
1.44      dsl       514:                        return;
1.1       jtc       515:                }
1.44      dsl       516:        } else
                    517:                etime = 1.0;
                    518:
1.63      dsl       519:        show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp);
1.1       jtc       520:
1.63      dsl       521:        /* Memory totals */
1.17      drochner  522: #define pgtokb(pg)     ((pg) * (s.uvmexp.pagesize / 1024))
1.82.4.1  pgoyette  523:
                    524:        putint(pgtokb(s.uvmexp.anonpages),                              MEMROW + 0, MEMCOL + 7, 10);
                    525:        putint((s.uvmexp.anonpages * 100 + 0.5) / s.uvmexp.npages,      MEMROW + 0, MEMCOL + 17, 4);
                    526:
                    527:        putint(pgtokb(s.uvmexp.zeropages),                              MEMROW + 0, MEMCOL + 30, 8);
                    528:
                    529:        putint(pgtokb(s.uvmexp.execpages),                              MEMROW + 1, MEMCOL + 7, 10);
                    530:        putint((s.uvmexp.execpages * 100 + 0.5) / s.uvmexp.npages,      MEMROW + 1, MEMCOL + 17, 4);
                    531:
                    532:        putint(pgtokb(s.uvmexp.wired),                                  MEMROW + 1, MEMCOL + 30, 8);
                    533:
                    534:        putint(pgtokb(s.uvmexp.filepages),                              MEMROW + 2, MEMCOL + 7, 10);
                    535:        putint((s.uvmexp.filepages * 100 + 0.5) / s.uvmexp.npages,      MEMROW + 2, MEMCOL + 17, 4);
                    536:
                    537:        putint(pgtokb(s.uvmexp.inactive),                               MEMROW + 2, MEMCOL + 30, 8);
                    538:
                    539:        /* Get total size of metadata buffers */
                    540:        size = sizeof(bufmem);
                    541:        if (sysctlbyname("vm.bufmem", &bufmem, &size, NULL, 0) < 0) {
                    542:                error("can't get buffers size: %s\n", strerror(errno));
                    543:                return;
                    544:        }
                    545:
                    546:        /* Get number of metadata buffers */
                    547:        size = 0;
                    548:        buffers = NULL;
                    549:        mib[0] = CTL_KERN;
                    550:        mib[1] = KERN_BUF;
                    551:        mib[2] = KERN_BUF_ALL;
                    552:        mib[3] = KERN_BUF_ALL;
                    553:        mib[4] = (int)sizeof(struct buf_sysctl);
                    554:        mib[5] = INT_MAX; /* we want them all */
                    555: again:
                    556:        if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0) {
                    557:                error("can't get buffers size: %s\n", strerror(errno));
                    558:                return;
                    559:        }
                    560:        if (size == 0) {
                    561:                error("buffers size is zero: %s\n", strerror(errno));
                    562:                return;
                    563:        }
                    564:        size += extraslop * sizeof(struct buf_sysctl);
                    565:        buffers = malloc(size);
                    566:        if (buffers == NULL) {
                    567:                error("can't allocate buffers: %s\n", strerror(errno));
                    568:                return;
                    569:        }
                    570:        if (sysctl(mib, 6, buffers, &size, NULL, 0) < 0) {
                    571:                free(buffers);
                    572:                if (extraslop == 0) {
                    573:                        extraslop = 100;
                    574:                        goto again;
                    575:                }
                    576:                error("can't get buffers: %s\n", strerror(errno));
                    577:                return;
                    578:        }
                    579:        free(buffers);                  /* XXX there must be a better way! */
                    580:        nbuf = size / sizeof(struct buf_sysctl);
                    581:
                    582:        putint((int) (bufmem / 1024),           MEMROW + 3, MEMCOL + 5, 12);
                    583:        putint((int) ((bufmem * 100) + 0.5) / s.uvmexp.pagesize / s.uvmexp.npages,
                    584:                                                MEMROW + 3, MEMCOL + 17, 4);
                    585:        putint(nbuf,                            MEMROW + 3, MEMCOL + 30, 8);
                    586:
                    587:        putint(pgtokb(s.uvmexp.active),         MEMROW + 5, MEMCOL + 7, 10);
                    588:        putint(pgtokb(s.uvmexp.swpgonly),       MEMROW + 5, MEMCOL + 18, 10);
                    589:        putint(pgtokb(s.uvmexp.free),           MEMROW + 5, MEMCOL + 28, 10);
                    590:
1.63      dsl       591: #undef pgtokb
                    592:
                    593:        /* Namei cache */
                    594:        Z(s, s1, ncs_goodhits); Z(s, s1, ncs_badhits); Z(s, s1, ncs_miss);
                    595:        Z(s, s1, ncs_long); Z(s, s1, ncs_pass2); Z(s, s1, ncs_2passes);
                    596:        s.nchcount = s.nchstats.ncs_goodhits + s.nchstats.ncs_badhits +
1.77      njoly     597:            s.nchstats.ncs_miss + s.nchstats.ncs_long +
                    598:            s.nchstats.ncs_pass2 + s.nchstats.ncs_2passes;
1.63      dsl       599:        if (display_mode == TIME)
                    600:                s1.nchcount = s.nchcount;
                    601:
                    602:        putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9);
                    603:        putint(s.nchstats.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 9, 9);
                    604: #define nz(x)  ((x) ? (x) : 1)
                    605:        putfloat(s.nchstats.ncs_goodhits * 100.0 / nz(s.nchcount),
                    606:           NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1);
                    607:        putint(s.nchstats.ncs_pass2, NAMEIROW + 2, NAMEICOL + 23, 9);
                    608:        putfloat(s.nchstats.ncs_pass2 * 100.0 / nz(s.nchcount),
                    609:           NAMEIROW + 2, NAMEICOL + 34, 4, 0, 1);
                    610: #undef nz
1.12      mrg       611:
1.63      dsl       612:        /* Disks */
1.61      blymn     613:        for (l = 0, i = 0, r = DISKROW, c = DISKCOL;
1.73      lukem     614:             i < (int)ndrive; i++) {
1.65      blymn     615:                if (!drv_select[i])
                    616:                        continue;
1.61      blymn     617:
1.49      dsl       618:                if (disk_horiz)
                    619:                        c += DISKCOLWIDTH;
                    620:                else
                    621:                        r++;
                    622:                if (c + DISKCOLWIDTH > DISKCOLEND) {
                    623:                        if (disk_horiz && LINES - 1 - DISKROW >
1.61      blymn     624:                            (DISKCOLEND - DISKCOL) / DISKCOLWIDTH) {
1.49      dsl       625:                                disk_horiz = 0;
                    626:                                relabel = 1;
                    627:                        }
                    628:                        break;
1.1       jtc       629:                }
1.49      dsl       630:                if (r >= LINES - 1) {
                    631:                        if (!disk_horiz && LINES - 1 - DISKROW <
1.61      blymn     632:                            (DISKCOLEND - DISKCOL) / DISKCOLWIDTH) {
1.49      dsl       633:                                disk_horiz = 1;
                    634:                                relabel = 1;
                    635:                        }
                    636:                        break;
                    637:                }
                    638:                l++;
                    639:
1.65      blymn     640:                dinfo(i, r, c);
1.49      dsl       641:        }
                    642:        /* blank out if we lost any disks */
                    643:        for (i = l; i < last_disks; i++) {
                    644:                int j;
                    645:                if (disk_horiz)
                    646:                        c += DISKCOLWIDTH;
                    647:                else
                    648:                        r++;
                    649:                for (j = 0; j < 5; j++) {
                    650:                        if (disk_horiz)
1.56      mycroft   651:                                mvprintw(r+j, c, "%*s", DISKCOLWIDTH, "");
1.49      dsl       652:                        else
1.56      mycroft   653:                                mvprintw(r, c+j*DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "");
1.49      dsl       654:                }
                    655:        }
                    656:        last_disks = l;
1.63      dsl       657:
                    658:        /* Interrupts */
                    659:        failcnt = 0;
                    660:        inttotal = 0;
                    661:        for (i = 0; i < nintr; i++) {
                    662:                if (s.intrcnt[i] == 0)
                    663:                        continue;
                    664:                if (intrloc[i] == 0) {
                    665:                        if (nextintsrow == LINES)
                    666:                                continue;
                    667:                        intrloc[i] = nextintsrow++;
                    668:                        mvprintw(intrloc[i], INTSCOL + 9, "%-.*s",
                    669:                                INTSCOLEND - (INTSCOL + 9), intrname[i]);
                    670:                }
                    671:                X(s, s1, intrcnt);
                    672:                l = (int)((float)s.intrcnt[i]/etime + 0.5);
                    673:                inttotal += l;
                    674:                putint(l, intrloc[i], INTSCOL, 8);
                    675:        }
                    676:
                    677:        for (i = 0; i < nevcnt; i++) {
                    678:                if (s.evcnt[i] == 0)
                    679:                        continue;
                    680:                if (ie_head[i].ie_loc == 0) {
                    681:                        if (nextintsrow == LINES)
                    682:                                continue;
                    683:                        ie_head[i].ie_loc = nextintsrow++;
                    684:                        print_ie_title(i);
                    685:                }
                    686:                X(s, s1, evcnt);
                    687:                l = (int)((float)s.evcnt[i]/etime + 0.5);
                    688:                inttotal += l;
                    689:                putint(l, ie_head[i].ie_loc, INTSCOL, 8);
                    690:        }
                    691:        putint(inttotal, INTSROW, INTSCOL, 8);
                    692:
                    693:        PUTRATE(s, s1, uvmexp.forks, VMSTATROW + 0, VMSTATCOL + 3, 6);
                    694:        PUTRATE(s, s1, uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6);
                    695:        PUTRATE(s, s1, uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6);
                    696:        PUTRATE(s, s1, uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5);
                    697:        PUTRATE(s, s1, uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6);
                    698:        PUTRATE(s, s1, uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6);
                    699:        PUTRATE(s, s1, uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6);
                    700:        PUTRATE(s, s1, uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6);
                    701:        PUTRATE(s, s1, uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6);
                    702:        PUTRATE(s, s1, uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6);
                    703:        PUTRATE(s, s1, uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9);
                    704:        putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9);
                    705:        putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9);
                    706:        putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9);
1.82.4.1  pgoyette  707:        putint(s.uvmexp.fltnoanon, VMSTATROW + 14, VMSTATCOL, 9);
1.63      dsl       708:        PUTRATE(s, s1, uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9);
                    709:        if (LINES - 1 > VMSTATROW + 16)
                    710:                PUTRATE(s, s1, uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9);
                    711:
1.1       jtc       712: }
                    713:
1.22      jwise     714: void
1.33      ad        715: vmstat_boot(char *args)
1.22      jwise     716: {
                    717:        copyinfo(&z, &s1);
1.63      dsl       718:        display_mode = BOOT;
1.22      jwise     719: }
                    720:
                    721: void
1.33      ad        722: vmstat_run(char *args)
1.22      jwise     723: {
                    724:        copyinfo(&s1, &s2);
1.63      dsl       725:        display_mode = RUN;
1.22      jwise     726: }
                    727:
                    728: void
1.44      dsl       729: vmstat_time(char *args)
1.1       jtc       730: {
1.63      dsl       731:        display_mode = TIME;
1.22      jwise     732: }
1.1       jtc       733:
1.22      jwise     734: void
1.33      ad        735: vmstat_zero(char *args)
1.22      jwise     736: {
1.63      dsl       737:        if (display_mode == RUN)
                    738:                getinfo(&s1);
1.1       jtc       739: }
                    740:
                    741: /* calculate number of users on the system */
                    742: static int
1.33      ad        743: ucount(void)
1.1       jtc       744: {
1.40      christos  745:        static int onusers = -1;
                    746:        int nusers = 0;
                    747:        struct utmpentry *ehead;
                    748:
                    749:        nusers = getutentries(NULL, &ehead);
1.1       jtc       750:
1.21      mrg       751:        if (nusers != onusers) {
                    752:                if (nusers == 1)
                    753:                        mvprintw(STATROW, STATCOL + 8, " ");
                    754:                else
                    755:                        mvprintw(STATROW, STATCOL + 8, "s");
                    756:        }
                    757:        onusers = nusers;
1.1       jtc       758:        return (nusers);
                    759: }
                    760:
                    761: static float
1.33      ad        762: cputime(int indx)
1.1       jtc       763: {
                    764:        double t;
1.10      lukem     765:        int i;
1.1       jtc       766:
                    767:        t = 0;
                    768:        for (i = 0; i < CPUSTATES; i++)
1.39      sommerfe  769:                t += cur.cp_time[i];
1.1       jtc       770:        if (t == 0.0)
                    771:                t = 1.0;
1.39      sommerfe  772:        return (cur.cp_time[indx] * 100.0 / t);
1.1       jtc       773: }
                    774:
1.63      dsl       775: void
1.44      dsl       776: puthumanint(u_int64_t n, int l, int c, int w)
1.41      abs       777: {
                    778:        char b[128];
                    779:
1.48      dsl       780:        if (move(l, c) != OK)
                    781:                return;
1.41      abs       782:        if (n == 0) {
                    783:                hline(' ', w);
                    784:                return;
                    785:        }
1.44      dsl       786:        if (humanize_number(b, w, n, "", HN_AUTOSCALE, HN_NOSPACE) == -1 ) {
1.41      abs       787:                hline('*', w);
                    788:                return;
                    789:        }
1.63      dsl       790:        printw("%*s", w, b);
1.41      abs       791: }
                    792:
1.63      dsl       793: void
1.33      ad        794: putint(int n, int l, int c, int w)
1.1       jtc       795: {
                    796:        char b[128];
                    797:
1.48      dsl       798:        if (move(l, c) != OK)
                    799:                return;
1.1       jtc       800:        if (n == 0) {
1.30      mycroft   801:                hline(' ', w);
1.1       jtc       802:                return;
                    803:        }
1.14      mrg       804:        (void)snprintf(b, sizeof b, "%*d", w, n);
1.73      lukem     805:        if ((int)strlen(b) > w) {
1.63      dsl       806:                if (display_mode == TIME)
                    807:                        hline('*', w);
                    808:                else
                    809:                        puthumanint(n, l, c, w);
1.1       jtc       810:                return;
                    811:        }
                    812:        addstr(b);
                    813: }
                    814:
1.63      dsl       815: void
1.33      ad        816: putfloat(double f, int l, int c, int w, int d, int nz)
1.1       jtc       817: {
                    818:        char b[128];
                    819:
1.48      dsl       820:        if (move(l, c) != OK)
                    821:                return;
1.1       jtc       822:        if (nz && f == 0.0) {
1.30      mycroft   823:                hline(' ', w);
1.1       jtc       824:                return;
                    825:        }
1.14      mrg       826:        (void)snprintf(b, sizeof b, "%*.*f", w, d, f);
1.73      lukem     827:        if ((int)strlen(b) > w) {
1.30      mycroft   828:                hline('*', w);
1.1       jtc       829:                return;
                    830:        }
                    831:        addstr(b);
                    832: }
                    833:
                    834: static void
1.63      dsl       835: getinfo(struct Info *stats)
1.1       jtc       836: {
1.4       cgd       837:        int mib[2];
                    838:        size_t size;
1.44      dsl       839:        int i;
1.1       jtc       840:
1.62      dsl       841:        cpureadstats();
1.65      blymn     842:        drvreadstats();
1.78      joerg     843:        size = sizeof(stats->nchstats);
                    844:        if (sysctlbyname("vfs.namecache_stats", &stats->nchstats, &size,
                    845:            NULL, 0) < 0) {
                    846:                error("can't get namecache statistics: %s\n", strerror(errno));
                    847:                memset(&stats->nchstats, 0, sizeof(stats->nchstats));
                    848:        }
1.60      chs       849:        if (nintr)
1.82.4.1  pgoyette  850:                NREAD(X_INTRCNT, stats->intrcnt, nintr * sizeof(long));
1.44      dsl       851:        for (i = 0; i < nevcnt; i++)
1.60      chs       852:                KREAD(ie_head[i].ie_count, &stats->evcnt[i],
                    853:                      sizeof stats->evcnt[i]);
1.59      dsl       854:        size = sizeof(stats->uvmexp);
1.11      mrg       855:        mib[0] = CTL_VM;
1.34      simonb    856:        mib[1] = VM_UVMEXP2;
1.59      dsl       857:        if (sysctl(mib, 2, &stats->uvmexp, &size, NULL, 0) < 0) {
1.11      mrg       858:                error("can't get uvmexp: %s\n", strerror(errno));
1.59      dsl       859:                memset(&stats->uvmexp, 0, sizeof(stats->uvmexp));
1.11      mrg       860:        }
1.59      dsl       861:        size = sizeof(stats->Total);
1.1       jtc       862:        mib[0] = CTL_VM;
                    863:        mib[1] = VM_METER;
1.59      dsl       864:        if (sysctl(mib, 2, &stats->Total, &size, NULL, 0) < 0) {
1.1       jtc       865:                error("Can't get kernel info: %s\n", strerror(errno));
1.59      dsl       866:                memset(&stats->Total, 0, sizeof(stats->Total));
1.1       jtc       867:        }
                    868: }
                    869:
                    870: static void
1.59      dsl       871: allocinfo(struct Info *stats)
1.1       jtc       872: {
                    873:
1.60      chs       874:        if (nintr &&
                    875:            (stats->intrcnt = calloc(nintr, sizeof(long))) == NULL) {
1.44      dsl       876:                error("calloc failed");
                    877:                die(0);
                    878:        }
1.59      dsl       879:        if ((stats->evcnt = calloc(nevcnt, sizeof(u_int64_t))) == NULL) {
1.44      dsl       880:                error("calloc failed");
1.23      jwise     881:                die(0);
                    882:        }
1.1       jtc       883: }
                    884:
                    885: static void
1.33      ad        886: copyinfo(struct Info *from, struct Info *to)
1.1       jtc       887: {
                    888:        long *intrcnt;
1.44      dsl       889:        u_int64_t *evcnt;
1.1       jtc       890:
1.5       thorpej   891:        intrcnt = to->intrcnt;
1.44      dsl       892:        evcnt = to->evcnt;
1.1       jtc       893:        *to = *from;
1.54      dsl       894:        memmove(to->intrcnt = intrcnt, from->intrcnt, nintr * sizeof *intrcnt);
1.44      dsl       895:        memmove(to->evcnt = evcnt, from->evcnt, nevcnt * sizeof *evcnt);
1.1       jtc       896: }
                    897:
                    898: static void
1.49      dsl       899: dinfo(int dn, int r, int c)
1.1       jtc       900: {
1.82      mlelstv   901:        double atime, dtime;
1.49      dsl       902: #define ADV if (disk_horiz) r++; else c += DISKCOLWIDTH
                    903:
1.82      mlelstv   904:        /* elapsed time for disk stats */
                    905:        dtime = etime;
                    906:        if (cur.timestamp[dn].tv_sec || cur.timestamp[dn].tv_usec) {
                    907:                dtime = (double)cur.timestamp[dn].tv_sec +
                    908:                        ((double)cur.timestamp[dn].tv_usec / (double)1000000);
                    909:        }
                    910:
1.49      dsl       911:        mvprintw(r, c, "%*.*s", DISKCOLWIDTH, DISKCOLWIDTH, dr_name[dn]);
                    912:        ADV;
1.1       jtc       913:
1.82      mlelstv   914:        putint((int)(cur.seek[dn]/dtime+0.5), r, c, DISKCOLWIDTH);
1.61      blymn     915:        ADV;
1.82      mlelstv   916:        putint((int)((cur.rxfer[dn]+cur.wxfer[dn])/dtime+0.5),
1.61      blymn     917:            r, c, DISKCOLWIDTH);
                    918:        ADV;
1.82      mlelstv   919:        puthumanint((cur.rbytes[dn] + cur.wbytes[dn]) / dtime + 0.5,
1.61      blymn     920:                    r, c, DISKCOLWIDTH);
                    921:        ADV;
                    922:
                    923:        /* time busy in disk activity */
1.65      blymn     924:        atime = cur.time[dn].tv_sec + cur.time[dn].tv_usec / 1000000.0;
1.82      mlelstv   925:        atime = atime * 100.0 / dtime;
1.61      blymn     926:        if (atime >= 100)
                    927:                putint(100, r, c, DISKCOLWIDTH);
                    928:        else
                    929:                putfloat(atime, r, c, DISKCOLWIDTH, 1, 1);
1.1       jtc       930: }

CVSweb <webmaster@jp.NetBSD.org>