summaryrefslogtreecommitdiff
path: root/usr.bin/systat/vmstat.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 11:36:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 11:36:02 +0000
commit806021be093ad00ce2022a532c0f4cc99b0065ac (patch)
treec4f374fc66dbd93cdd093f4e1213808e855c8b39 /usr.bin/systat/vmstat.c
parent200dde568cd8db5fa9ddc42e6b5388df55a16573 (diff)
libutil
Diffstat (limited to 'usr.bin/systat/vmstat.c')
-rw-r--r--usr.bin/systat/vmstat.c77
1 files changed, 26 insertions, 51 deletions
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index ce8e74da457..4db84af9ccb 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.4 1995/04/29 05:54:55 cgd Exp $ */
+/* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */
/*-
* Copyright (c) 1983, 1989, 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-static char rcsid[] = "$NetBSD: vmstat.c,v 1.4 1995/04/29 05:54:55 cgd Exp $";
+static char rcsid[] = "$NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $";
#endif /* not lint */
/*
@@ -72,16 +72,15 @@ static struct Info {
long time[CPUSTATES];
struct vmmeter Cnt;
struct vmtotal Total;
- long *dk_time;
- long *dk_wds;
- long *dk_seek;
- long *dk_xfer;
- int dk_busy;
struct nchstats nchstats;
long nchcount;
long *intrcnt;
} s, s1, s2, z;
+#include "dkstats.h"
+extern struct _disk cur;
+
+
#define cnt s.Cnt
#define oldcnt s1.Cnt
#define total s.Total
@@ -215,7 +214,7 @@ initkre()
}
}
hertz = stathz ? stathz : hz;
- if (! dkinit())
+ if (! dkinit(1))
return(0);
if (dk_ndrive && !once) {
#define allocate(e, t) \
@@ -223,10 +222,6 @@ initkre()
s1./**/e = (t *)calloc(dk_ndrive, sizeof (t)); \
s2./**/e = (t *)calloc(dk_ndrive, sizeof (t)); \
z./**/e = (t *)calloc(dk_ndrive, sizeof (t));
- allocate(dk_time, long);
- allocate(dk_wds, long);
- allocate(dk_seek, long);
- allocate(dk_xfer, long);
once = 1;
#undef allocate
}
@@ -331,8 +326,8 @@ labelkre()
mvprintw(DISKROW, DISKCOL, "Discs");
mvprintw(DISKROW + 1, DISKCOL, "seeks");
mvprintw(DISKROW + 2, DISKCOL, "xfers");
- mvprintw(DISKROW + 3, DISKCOL, " blks");
- mvprintw(DISKROW + 4, DISKCOL, " msps");
+ mvprintw(DISKROW + 3, DISKCOL, "Kbyte");
+ mvprintw(DISKROW + 4, DISKCOL, " sec");
j = 0;
for (i = 0; i < dk_ndrive && j < MAXDRIVES; i++)
if (dk_select[i]) {
@@ -367,9 +362,9 @@ showkre()
int i, l, c;
static int failcnt = 0;
- for (i = 0; i < dk_ndrive; i++) {
- X(dk_xfer); X(dk_seek); X(dk_wds); X(dk_time);
- }
+
+ if (state == TIME)
+ dkswap();
etime = 0;
for(i = 0; i < CPUSTATES; i++) {
X(time);
@@ -617,13 +612,9 @@ getinfo(s, st)
size_t size;
extern int errno;
+ dkreadstats();
NREAD(X_CPTIME, s->time, sizeof s->time);
NREAD(X_CNT, &s->Cnt, sizeof s->Cnt);
- NREAD(X_DK_BUSY, &s->dk_busy, LONG);
- NREAD(X_DK_TIME, s->dk_time, dk_ndrive * LONG);
- NREAD(X_DK_XFER, s->dk_xfer, dk_ndrive * LONG);
- NREAD(X_DK_WDS, s->dk_wds, dk_ndrive * LONG);
- NREAD(X_DK_SEEK, s->dk_seek, dk_ndrive * LONG);
NREAD(X_NCHSTATS, &s->nchstats, sizeof s->nchstats);
NREAD(X_INTRCNT, s->intrcnt, nintr * LONG);
size = sizeof(s->Total);
@@ -649,21 +640,10 @@ static void
copyinfo(from, to)
register struct Info *from, *to;
{
- long *time, *wds, *seek, *xfer;
long *intrcnt;
- /*
- * time, wds, seek, and xfer are malloc'd so we have to
- * save the pointers before the structure copy and then
- * copy by hand.
- */
- time = to->dk_time; wds = to->dk_wds; seek = to->dk_seek;
- xfer = to->dk_xfer; intrcnt = to->intrcnt;
+ intrcnt = to->intrcnt;
*to = *from;
- bcopy(from->dk_time, to->dk_time = time, dk_ndrive * sizeof (long));
- bcopy(from->dk_wds, to->dk_wds = wds, dk_ndrive * sizeof (long));
- bcopy(from->dk_seek, to->dk_seek = seek, dk_ndrive * sizeof (long));
- bcopy(from->dk_xfer, to->dk_xfer = xfer, dk_ndrive * sizeof (long));
bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int));
}
@@ -671,23 +651,18 @@ static void
dinfo(dn, c)
int dn, c;
{
- double words, atime, itime, xtime;
+ double words, atime;
c = DISKCOL + c * 5;
- atime = s.dk_time[dn];
- atime /= hertz;
- words = s.dk_wds[dn]*32.0; /* number of words transferred */
- xtime = dk_mspw[dn]*words; /* transfer time */
- itime = atime - xtime; /* time not transferring */
- if (xtime < 0)
- itime += xtime, xtime = 0;
- if (itime < 0)
- xtime += itime, itime = 0;
- putint((int)((float)s.dk_seek[dn]/etime+0.5), DISKROW + 1, c, 5);
- putint((int)((float)s.dk_xfer[dn]/etime+0.5), DISKROW + 2, c, 5);
- putint((int)(words/etime/512.0 + 0.5), DISKROW + 3, c, 5);
- if (s.dk_seek[dn])
- putfloat(itime*1000.0/s.dk_seek[dn], DISKROW + 4, c, 5, 1, 1);
- else
- putint(0, DISKROW + 4, c, 5);
+
+ /* time busy in disk activity */
+ atime = (double)cur.dk_time[dn].tv_sec +
+ ((double)cur.dk_time[dn].tv_usec / (double)1000000);
+
+ words = cur.dk_bytes[dn] / 1024.0; /* # of K transferred */
+
+ putint((int)((float)cur.dk_seek[dn]/etime+0.5), DISKROW + 1, c, 5);
+ putint((int)((float)cur.dk_xfer[dn]/etime+0.5), DISKROW + 2, c, 5);
+ putint((int)(words/etime + 0.5), DISKROW + 3, c, 5);
+ putfloat(atime/etime, DISKROW + 4, c, 5, 1, 1);
}