Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src iostat(8) and systat(8) support for separate read/write disk...



details:   https://anonhg.NetBSD.org/src/rev/19762f6758a7
branches:  trunk
changeset: 538851:19762f6758a7
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Nov 01 12:47:55 2002 +0000

description:
iostat(8) and systat(8) support for separate read/write disk statistics.
"iostat -x" now shows these (ala linux/solaris), but this is only splitting
the read/write bytes/transactions, not adding any new metrics.  "systat
iostat" now has two new commands to switch between combined/separate mode
for both it's numbers & bar modes.

diffstat:

 usr.bin/systat/cmdtab.c  |   6 ++-
 usr.bin/systat/extern.h  |   4 +-
 usr.bin/systat/iostat.c  |  90 +++++++++++++++++++++++++++++++++++++----------
 usr.bin/systat/systat.1  |   6 ++-
 usr.bin/systat/vmstat.c  |  10 +++--
 usr.bin/vmstat/dkstats.c |  66 +++++++++++++++++++++++++---------
 usr.bin/vmstat/dkstats.h |   8 ++-
 usr.bin/vmstat/vmstat.c  |  14 ++++---
 usr.sbin/iostat/iostat.8 |   3 +-
 usr.sbin/iostat/iostat.c |  82 +++++++++++++++++++++++++++----------------
 10 files changed, 203 insertions(+), 86 deletions(-)

diffs (truncated from 677 to 300 lines):

diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/systat/cmdtab.c
--- a/usr.bin/systat/cmdtab.c   Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/systat/cmdtab.c   Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03:21 ad Exp $   */
+/*     $NetBSD: cmdtab.c,v 1.17 2002/11/01 12:47:57 mrg Exp $  */
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)cmdtab.c   8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03:21 ad Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.17 2002/11/01 12:47:57 mrg Exp $");
 #endif /* not lint */
 
 #include "systat.h"
@@ -71,6 +71,8 @@
        { "bars",       iostat_bars,    "show io stats as a bar graph"},
        { "numbers",    iostat_numbers, "show io stats numerically"},
        { "secs",       iostat_secs,    "include time statistics"},
+       { "rw",         iostat_rw,      "show read/write disk stats"},
+       { "all",        iostat_all,     "show combiend disk stats"},
        /* from disks.c */
        { "add",        disks_add,      "add a disk to displayed disks"},
        { "show",       disks_add,      "add a disk to displayed disks"},
diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/systat/extern.h
--- a/usr.bin/systat/extern.h   Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/systat/extern.h   Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.27 2001/07/14 07:09:11 matt Exp $ */
+/*     $NetBSD: extern.h,v 1.28 2002/11/01 12:47:57 mrg Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -126,6 +126,8 @@
 void    iostat_bars(char *);
 void    iostat_numbers(char *);
 void    iostat_secs(char *);
+void    iostat_rw(char *);
+void    iostat_all(char *);
 void    ip_boot(char *);
 void    ip_run(char *);
 void    ip_time(char *);
diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/systat/iostat.c
--- a/usr.bin/systat/iostat.c   Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/systat/iostat.c   Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iostat.c,v 1.22 2002/09/25 13:50:39 christos Exp $     */
+/*     $NetBSD: iostat.c,v 1.23 2002/11/01 12:47:57 mrg Exp $  */
 
 /*
  * Copyright (c) 1980, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)iostat.c   8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: iostat.c,v 1.22 2002/09/25 13:50:39 christos Exp $");
+__RCSID("$NetBSD: iostat.c,v 1.23 2002/11/01 12:47:57 mrg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -53,6 +53,7 @@
 static  double etime;
 static  int numbers = 0;               /* default display bar graphs */
 static  int secs = 0;                  /* default seconds shown */
+static  int read_write = 0;            /* default read/write shown */
 
 static int barlabels(int);
 static void histogram(double, int, double);
@@ -128,7 +129,7 @@
 {
        int i, col, regions, ndrives;
 
-#define COLWIDTH       14
+#define COLWIDTH       (read_write ? 24 : 14)
 #define DRIVESPERLINE  ((getmaxx(wnd) - 1) / COLWIDTH)
        for (ndrives = 0, i = 0; i < dk_ndrive; i++)
                if (cur.dk_select[i])
@@ -146,14 +147,19 @@
                linesperregion = 3;
        col = 0;
        for (i = 0; i < dk_ndrive; i++)
-               if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
+               if (cur.dk_select[i]) {
                        if (col + COLWIDTH > getmaxx(wnd)) {
                                col = 0, row += linesperregion + 1;
                                if (row > getmaxy(wnd) - (linesperregion + 1))
                                        break;
                        }
-                       mvwaddstr(wnd, row, col + 4, cur.dk_name[i]);
-                       mvwaddstr(wnd, row + 1, col, "kBps tps  sec");
+                       mvwprintw(wnd, row, col + 4, "%s%s",
+                           cur.dk_name[i], read_write ? "       (write)" : "");
+                       if (read_write)
+                               mvwaddstr(wnd, row + 1, col,
+                                   "kBps r/s  sec kBps w/s");
+                       else
+                               mvwaddstr(wnd, row + 1, col, "kBps tps  sec");
                        col += COLWIDTH;
                }
        if (col)
@@ -168,13 +174,18 @@
 
        mvwaddstr(wnd, row++, INSET,
            "/0   /10  /20  /30  /40  /50  /60  /70  /80  /90  /100");
-       linesperregion = 2 + secs;
+       linesperregion = 2 + secs + (read_write ? 2 : 0);
        for (i = 0; i < dk_ndrive; i++)
-               if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
+               if (cur.dk_select[i]) {
                        if (row > getmaxy(wnd) - linesperregion)
                                break;
-                       mvwprintw(wnd, row++, 0, "%7.7s  kBps|", cur.dk_name[i]);
+                       mvwprintw(wnd, row++, 0, "%7.7s  kBps|", cur.dk_name[i],
+                           read_write ? ' ' : 'r');
                        mvwaddstr(wnd, row++, 0, "          tps|");
+                       if (read_write) {
+                               mvwprintw(wnd, row++, 0, " (write) kBps|");
+                               mvwaddstr(wnd, row++, 0, "          tps|");
+                       }
                        if (secs)
                                mvwaddstr(wnd, row++, 0, "         msec|");
                }
@@ -201,7 +212,7 @@
        if (!numbers) {
                row += 2;
                for (i = 0; i < dk_ndrive; i++)
-                       if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
+                       if (cur.dk_select[i]) {
                                if (row > getmaxy(wnd) - linesperregion)
                                        break;
                                row = stats(row, INSET, i);
@@ -214,7 +225,7 @@
        wmove(wnd, row + 3, 0);
        winsertln(wnd);
        for (i = 0; i < dk_ndrive; i++)
-               if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
+               if (cur.dk_select[i]) {
                        if (col + COLWIDTH > getmaxx(wnd)) {
                                col = 0, row += linesperregion + 1;
                                if (row > getmaxy(wnd) - (linesperregion + 1))
@@ -232,22 +243,45 @@
 static int
 stats(int row, int col, int dn)
 {
-       double atime, words;
+       double atime, rwords, wwords;
 
        /* 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 */
+       /* # of k transferred */
+       rwords = cur.dk_rbytes[dn] / 1024.0;
+       wwords = cur.dk_wbytes[dn] / 1024.0;
        if (numbers) {
-               mvwprintw(wnd, row, col, " %3.0f%4.0f%5.1f",
-                   words / etime, cur.dk_xfer[dn] / etime, atime / etime);
+               if (read_write)
+                       mvwprintw(wnd, row, col, " %3.0f%4.0f%5.1f %3.0f%4.0f",
+                           rwords / etime, cur.dk_rxfer[dn] / etime,
+                           atime / etime,
+                           wwords / etime, cur.dk_wxfer[dn] / etime);
+               else
+                       mvwprintw(wnd, row, col, " %3.0f%4.0f%5.1f",
+                           (rwords + wwords) / etime,
+                           (cur.dk_rxfer[dn] + cur.dk_wxfer[dn]) / etime,
+                           atime / etime);
                return (row);
        }
-       wmove(wnd, row++, col);
-       histogram(words / etime, 50, 0.5);
-       wmove(wnd, row++, col);
-       histogram(cur.dk_xfer[dn] / etime, 50, 0.5);
+
+       if (read_write) {
+               wmove(wnd, row++, col);
+               histogram(rwords / etime, 50, 0.5);
+               wmove(wnd, row++, col);
+               histogram(cur.dk_rxfer[dn] / etime, 50, 0.5);
+               wmove(wnd, row++, col);
+               histogram(wwords / etime, 50, 0.5);
+               wmove(wnd, row++, col);
+               histogram(cur.dk_wxfer[dn] / etime, 50, 0.5);
+       } else {
+               wmove(wnd, row++, col);
+               histogram((rwords + wwords) / etime, 50, 0.5);
+               wmove(wnd, row++, col);
+               histogram((cur.dk_rxfer[dn] + cur.dk_wxfer[dn]) / etime, 50, 0.5);
+       }
+
        if (secs) {
                wmove(wnd, row++, col);
                atime *= 1000;  /* In milliseconds */
@@ -319,3 +353,21 @@
        labeliostat();
        refresh();
 }
+
+void
+iostat_rw(char *args)
+{
+       read_write = 1;
+       wclear(wnd);
+       labeliostat();
+       refresh();
+}
+
+void
+iostat_all(char *args)
+{
+       read_write = 0;
+       wclear(wnd);
+       labeliostat();
+       refresh();
+}
diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/systat/systat.1
--- a/usr.bin/systat/systat.1   Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/systat/systat.1   Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: systat.1,v 1.25 2002/02/08 01:36:33 ross Exp $
+.\"    $NetBSD: systat.1,v 1.26 2002/11/01 12:47:58 mrg Exp $
 .\"
 .\" Copyright (c) 1985, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -258,6 +258,10 @@
 .It Cm secs
 Toggle the display of time in disk activity (the default is to
 not display time).
+.It Cm all
+Show the read and write statistics combined (default).
+.It Cm rw
+Show the read and write statistics separately.
 .El
 .It Ic mbufs
 Display, in the lower window, the number of mbufs allocated
diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/systat/vmstat.c
--- a/usr.bin/systat/vmstat.c   Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/systat/vmstat.c   Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmstat.c,v 1.42 2002/09/25 13:50:40 christos Exp $     */
+/*     $NetBSD: vmstat.c,v 1.43 2002/11/01 12:47:58 mrg Exp $  */
 
 /*-
  * Copyright (c) 1983, 1989, 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 1/12/94";
 #endif
-__RCSID("$NetBSD: vmstat.c,v 1.42 2002/09/25 13:50:40 christos Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.43 2002/11/01 12:47:58 mrg Exp $");
 #endif /* not lint */
 
 /*
@@ -630,10 +630,12 @@
        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 */
+       /* # of k transferred */
+       words = (cur.dk_rbytes[dn] | cur.dk_wbytes[dn]) / 1024.0;
 
        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)((float)(cur.dk_rxfer[dn]+cur.dk_wxfer[dn])/etime+0.5),
+           DISKROW + 2, c, 5);
        puthumanint((int)(words/etime + 0.5), DISKROW + 3, c, 5);
        if (atime*100.0/etime >= 100)
                putint(100, DISKROW + 4, c, 5);
diff -r daf518b2cad0 -r 19762f6758a7 usr.bin/vmstat/dkstats.c
--- a/usr.bin/vmstat/dkstats.c  Fri Nov 01 11:31:50 2002 +0000
+++ b/usr.bin/vmstat/dkstats.c  Fri Nov 01 12:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dkstats.c,v 1.16 2002/06/30 00:10:34 sommerfeld Exp $  */
+/*     $NetBSD: dkstats.c,v 1.17 2002/11/01 12:47:56 mrg Exp $ */
 
 /*
  * Copyright (c) 1996 John M. Vinopal
@@ -131,9 +131,11 @@
                        continue;
 
                /* Delta Values. */
-               SWAP(dk_xfer[i]);
+               SWAP(dk_rxfer[i]);
+               SWAP(dk_wxfer[i]);
                SWAP(dk_seek[i]);
-               SWAP(dk_bytes[i]);
+               SWAP(dk_rbytes[i]);
+               SWAP(dk_wbytes[i]);
 
                /* Delta Time. */
                timerclear(&tmp_timer);
@@ -178,14 +180,17 @@
        if (memf == NULL) {
                mib[0] = CTL_HW;
                mib[1] = HW_DISKSTATS;
+               mib[2] = sizeof(struct disk_sysctl);



Home | Main Index | Thread Index | Old Index