Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/iostat Significant changes to output layout methods...



details:   https://anonhg.NetBSD.org/src/rev/bf25df08c081
branches:  trunk
changeset: 366842:bf25df08c081
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Jun 18 11:33:13 2022 +0000

description:
Significant changes to output layout methods - except for -x and -y
which have not (yet) been touched (-xD needs *serious* improvements).

While this still has no run-time configurability, it is now easy to
adjust the column widths in the source and recompile.  Dynamic (auto)
column width sizing is probably out of the question (requires predicting
the future) but options to allow the widths to be set isn't out of the
question.

The columns are now (mostly) considerably wider than they were before,
hence wider windows are needed to view the same info.  In an 80
column window the default display (with tty & cpu included) displays
just 2 drives.   160 columns will fit 7 (but with -I, just 4).

One new option added (-z) suppresses output which is true 0 (but still
prints 0 for values rounded down to 0) for everything except tty stats.
For drive output, the drive must have done nothing during the interval
to get its output data blanked.

Also options -H h -W w to set the output size (page height & width), the
former used to decide when to print headers, and the latter to calculate
the number of drives to print when no drive names were given.  Env vars
LINES and COLUMNS are used if the options are not given, with fallback
to the terminal size (if output is to a terminal, and its sizes are
known), and if all else fails, 20 lines, 80 columns.  Specifying 0
means unlimited (infinite).   So "iostat -W 0" will show all of the
drives, across one (often very) long line.  Wedges count as drives.

When drives are specified, the output will now appear in the order they were
given on the command line, rather than the order the system discovered them
during auto-configuration.  If specified as an fnmatch(3) pattern, drives that
match will appear in auto-conf order, but that's generally what is wanted.
When none are specified, you still get the first N (however many fits based
upon the options selected) in auto-conf order (usually useless, more so now
given that less will fit).

Lastly, for those who looked at the patch I sent to current-users@
and were horrified at how kludgey it was, rest assured, that was just
a quick hack to demonstrate what the output format changes would look
like.   This version (I hope) is not nearly so disgusting.

diffstat:

 usr.sbin/iostat/iostat.8 |  157 +++++++++++++--
 usr.sbin/iostat/iostat.c |  450 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 497 insertions(+), 110 deletions(-)

diffs (truncated from 993 to 300 lines):

diff -r b368bc043f14 -r bf25df08c081 usr.sbin/iostat/iostat.8
--- a/usr.sbin/iostat/iostat.8  Sat Jun 18 08:22:10 2022 +0000
+++ b/usr.sbin/iostat/iostat.8  Sat Jun 18 11:33:13 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: iostat.8,v 1.27 2018/07/29 21:17:43 wiz Exp $
+.\"    $NetBSD: iostat.8,v 1.28 2022/06/18 11:33:13 kre Exp $
 .\"
 .\" Copyright (c) 1985, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    from: @(#)iostat.8      8.1 (Berkeley) 6/6/93
 .\"
-.Dd July 29, 2018
+.Dd June 18, 2022
 .Dt IOSTAT 8
 .Os
 .Sh NAME
@@ -37,8 +37,10 @@
 .Nd report I/O statistics
 .Sh SYNOPSIS
 .Nm
-.Op Fl CdDITxy
+.Op Fl CdDITxyz
 .Op Fl c Ar count
+.Op Fl H Ar height
+.Op Fl W Ar width
 .Op Fl w Ar wait
 .Op Ar drives
 .Sh DESCRIPTION
@@ -49,6 +51,8 @@
 displays one line of statistics averaged over the machine's run time.
 The use of
 .Fl c
+or
+.Fl w
 presents successive lines averaged over the
 .Ar wait
 period.
@@ -56,13 +60,14 @@
 .Fl I
 option causes
 .Nm
-to print raw, unaveraged values.
+to print raw, unaveraged values (totals).
 .Pp
 Only the last disk option specified
 .Fl ( d ,
 .Fl D ,
+.Fl x ,
 or
-.Fl x )
+.Fl y )
 is used.
 .Pp
 The options are as follows:
@@ -80,34 +85,86 @@
 interval is specified, the default is 1 second.
 .It Fl C
 Show CPU statistics.
-This is enabled by default unless the
+This is enabled by default unless any of the
 .Fl d ,
 .Fl D ,
 .Fl T ,
+.Fl x ,
 or
-.Fl x
+.Fl y
 flags are used.
 .It Fl d
 Show disk statistics.
 This is the default.
-Displays kilobytes per
-transfer, number of transfers, and megabytes transferred.
-Use of this flag disables display of CPU and tty statistics.
+Displays
+number of transfers per second,
+kilobytes per transfer,
+and
+megabytes transferred per second.
+Use of this flag disables the default display of CPU and tty statistics.
 .It Fl D
 Show alternative disk statistics.
-Displays kilobytes transferred, number of
-transfers, and time spent in transfers.
+Displays
+number of transfers,
+kilobytes transferred,
+and
+time spent in transfers,
+during the
+.Ar wait
+period (or since boot with
+.Fl I ) .
 Use of this flag disables the default display.
+.It Fl H Ar height
+Set the page size (length, or height) explicitly, as the number of lines,
+.Ar height .
+If not set, the page length is taken from the environment variable
+.Ev LINES
+if set, or from the terminal (window) size, if output is to a terminal
+and its size is set,
+and otherwise defaults to 20.
+If explicitly set to zero, pages are considered to be infinitely long.
+This parameter determines the frequency at which repeated headers are output.
+If the value is greater than zero, but too small for the header, along with
+one output set, then a new header will be produced for each set of output.
 .It Fl I
 Show the running total values, rather than an average.
+.ig ii
+.It Fl i
+Like
+.Fl I
+except the totals shown are those since
+.Nm
+started running, rather than since the system booted.
+In this case the first output would necessarily be zero,
+so is suppressed.
+Consequently this option produces no output if neither
+.Fl w
+nor
+.Fl c
+is given.
+.ii
 .It Fl T
 Show tty statistics.
-This is enabled by default unless the
+This is enabled by default unless one, or more, of the
 .Fl C ,
 .Fl d ,
+.Fl D ,
+.Fl x ,
 or
-.Fl D
+.Fl y
 flags are used.
+.ig uu
+.It Fl u
+When totals are being shown
+.Pq Fl I
+.ig ii
+.Po or
+.Fl i Pc
+.ii
+include a column after each relevant output column
+showing the difference between this output and the previous.
+These added columns will be blank in the first displayed output.
+.uu
 .It Fl w Ar wait
 Pause
 .Ar wait
@@ -115,16 +172,51 @@
 If no repeat
 .Ar count
 is specified, the default is infinity.
+.It Fl W Ar width
+Set the page width explicitly, as the number of columns of characters,
+.Ar width .
+If not set, the page width is taken from the environment variable
+.Ev COLUMNS
+if set, or from the terminal (window) size, if output is to a terminal
+and its size is set,
+and otherwise defaults to 80.
+If explicitly set to 0, lines are considered infinitely long.
+This width is used only to determine the number of drives to display
+by default when no drive list is given.
+In other cases output will be as wide as needed to display the
+data requested.
 .It Fl x
 Show extended disk statistics.
 Each disk is displayed on a line of its own with all available
 statistics.
 This option overrides all other display options, and all
-disks are displayed unless specific disks
+disks are displayed unless specific disk names
 are provided as arguments.
 Additionally, separate read and write statistics are displayed.
+The
+.Fl C
+and
+.Fl T
+options are ignored with this output format.
 .It Fl y
-Shows the extended statistics and additional queuing statistics.
+Shows the extended statistics (as with
+.Fl x )
+and additional queuing statistics.
+Output does not fit in an 80 column window.
+The
+.Fl C
+and
+.Fl T
+options are ignored with this output format.
+.It Fl z
+Replaces drive and CPU statistic outputs that are exactly zero with spaces.
+Note that zero values can still appear \(en this indicates a
+value that was not zero, but was rounded down so appears as zero.
+Drive output is replaced by spaces only when the drive did no
+input or output at all in the interval,
+or with
+.Fl I ,
+has never done any I/O.
 .El
 .Pp
 .Nm
@@ -152,27 +244,29 @@
 patterns.
 .Pp
 .Bl -tag -width indent -compact
+.It t/s
+transfers per second
 .It KB/t
 Kilobytes transferred per disk transfer
-.It t/s
-transfers per second
 .It MB/s
 Megabytes transferred per second
 .El
+.Pp
 The alternative display format, (selected with
 .Fl D ) ,
-presents the following values.
+presents the following values:
 .Bl -tag -width indent -compact
+.It xfr
+Disk transfers
 .It KB
 Kilobytes transferred
-.It xfr
-Disk transfers
 .It time
 Seconds spent in disk activity
 .El
+.Pp
 With the
 .Fl y
-flag, the following queuing measurements are added
+flag, the following queuing measurements are added:
 .Bl -tag -width indent -compact
 .It wait
 Number of I/O requests queued up
@@ -200,6 +294,9 @@
 .It \&id
 % of CPU time in idle mode
 .El
+.Pp
+Note that because of rounding, these percentages may
+appear to total more or less than 100.
 .El
 .Sh SEE ALSO
 .Xr fstat 1 ,
@@ -221,7 +318,21 @@
 .Fl x
 option was added in
 .Nx 1.4 .
-Collection of queueing values and the
+Collection of queuing values and the
 .Fl y
 option were added in
 .Nx 8.0 .
+The archaic option format:
+.br
+.ti +3n
+.Nm
+.Op Ar drives ...
+.Oo Ar wait Op Ar count Oc
+.br
+remains supported (the first
+.Ar drive
+whose name starts with a digit is taken to be the
+.Ar wait
+period) but is deprecated,
+and may be removed in a future version,
+so should not be used.
diff -r b368bc043f14 -r bf25df08c081 usr.sbin/iostat/iostat.c
--- a/usr.sbin/iostat/iostat.c  Sat Jun 18 08:22:10 2022 +0000
+++ b/usr.sbin/iostat/iostat.c  Sat Jun 18 11:33:13 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iostat.c,v 1.68 2022/06/17 01:47:45 kre Exp $  */
+/*     $NetBSD: iostat.c,v 1.69 2022/06/18 11:33:13 kre Exp $  */
 
 /*
  * Copyright (c) 1996 John M. Vinopal
@@ -71,7 +71,7 @@
 #if 0
 static char sccsid[] = "@(#)iostat.c   8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: iostat.c,v 1.68 2022/06/17 01:47:45 kre Exp $");
+__RCSID("$NetBSD: iostat.c,v 1.69 2022/06/18 11:33:13 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,7 +99,12 @@
 static int     winlines = 20;
 static int     wincols = 80;
 
+static int *order, ordersize;
+
+static char Line_Marker[] = "________________________________________________";



Home | Main Index | Thread Index | Old Index