Home | History | Annotate | Download | only in iostat
History log of /src/usr.sbin/iostat/iostat.c
RevisionDateAuthorComments
 1.72  30-Oct-2023  mrg fix rev 1.70: -X is 1 line output, avoids printing the header too often.
 1.71  28-Jul-2023  wiz ostat: use standard option order (AaBb...)

Fix macro usage while here
 1.70  28-Jul-2023  mrg add iostat -X option, limited alternative statistics.

this is like the "-D" option, except it skips the xfers/s, and
reports MB/s instead of KB/s. allows for far more devices to
be displayed per line by default (about 50% more.)
 1.69  18-Jun-2022  kre 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.
 1.68  17-Jun-2022  kre Fix processing of the archaic arg format (BACKWARD_COMPATIBILITY) so it
doesn't repeat the processing every iteration. Repeatedly seeing the wait
interval does no harm, but setting the iteration count (reps) over and
over again rather defeats its purpose.
 1.67  08-Apr-2018  mlelstv branches: 1.67.4;
Re-evaluate drive selection to catch hog-plug devices.
 1.66  09-Sep-2017  mrg branches: 1.66.2;
two minor fixes for -x and -y mode:
- the header is only 1 line not 2, account for this when calculating
when to display the next header.
- when ndrives > 1, don't display the header every time, but only when
the previous one disappears.

now i don't feel the need to run "iostat -x wd0 1 & iostat -c wd1 1"
to get less repeated header output on my display.
 1.65  04-Jul-2017  mlelstv Use I/O timestamps to compute disk statistics for better precision.

Disk statistics are collected in a fixed size array, that got corrupted
when a disk was detached. Adapt by skipping entries of detached disks
and detect reused disknames at the array end.
 1.64  05-Mar-2017  mlelstv branches: 1.64.4;
Enhance disk metrics by calculating a weighted sum that is incremented
by the number of concurrent I/O requests. Also introduce a new disk_wait()
function to measure requests waiting in a bufq.
iostat -y now reports data about waiting and active requests.

So far only drivers using dksubr and dk, ccd, wd and xbd collect data about
waiting requests.
 1.63  25-Oct-2015  mrg branches: 1.63.2; 1.63.4;
extend the "tout" column to 5 characters, it's really common on a modern
machine to have eg, build output way more than 9999 chars/sec.

this doesn't affect the default disk list on an 80-char wide screen.
 1.62  09-Jul-2015  mrg support fnmatch(3) patterns for disknames. eg, "iostat wd*" works now.
update the default disk number selection to note that it uses the current
terminal size to fit disks, not hard coded 4.
 1.61  11-Jun-2014  joerg branches: 1.61.2;
Remove KVM related options.
 1.60  30-Aug-2011  joerg branches: 1.60.8; 1.60.18;
static + __dead
 1.59  14-Feb-2011  enami A number greater than or equal to 1.0 is a positive number.
 1.58  14-Feb-2011  enami Put space after comma and around binary operator.
 1.57  09-Jan-2011  jakllsch branches: 1.57.2;
Fix copy/paste error that resulted in a extra space after the KB/t column.
 1.56  09-Jan-2011  jakllsch NetBSD/vax libm now has fmax, use it again.
Also, display average transfer size using dynamic precision too.
 1.55  08-Jan-2011  jakllsch NetBSD/vax does not implement fmax(3), substitute with existing MAX() macro.
 1.54  07-Jan-2011  jakllsch Maintain 5-character width of MB/s column by dynamically adjusting the
decimal precision.

This should work until disk transfer rates exceed 99999 MB/s.
 1.53  15-Apr-2009  lukem Fix -Wsign-compare issues
 1.52  21-Jul-2008  lukem branches: 1.52.6;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.51  24-Jun-2007  christos branches: 1.51.12;
add parens.
 1.50  26-Jul-2006  simonb Since the swapping of tk_nin and tk_nout was moved to its own
function (tkswap()), actually call this function.

Fixes problems where the tin/tout fields showed total tty IO since
boot instead of just what has happened in the last second.
 1.49  14-Apr-2006  blymn Update to use the new kernel io statistics.
 1.48  12-Feb-2006  dsl Need to read and swap cpustats separately from the dkstats.
I wonder how many more programs use the code in vmstat/dkstats.c
 1.47  12-Feb-2006  yamt print a header on each outputs if and only if the output has 2 or more lines.
 1.46  08-Jan-2006  yamt reset hdrcnt whenever printing a header.
 1.45  07-Aug-2005  blymn Add tape statistics.
 1.44  07-Jul-2005  mrg apply the patch from PR#30680: always print the header in extended
(-x) mode, as it is much easier to see what is going on.
 1.43  29-Oct-2004  dsl Add (unsigned char) cast to ctype functions
 1.42  25-Feb-2004  dbj for -x -I output, use just MB instead of MB/s in header
 1.41  13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.40  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.39  04-Aug-2003  mrg - convert header() away from a signal function (it does all sorts of stdio
and more) and use a little sig_header() helper.
- in selectdrives() make sure we don't overwrite some arrays. this makes
"iostat 1" work again on my really wide screens where defdrives (number that
can fit) was > ndrives (number of drives), rather than dump core trying to
print (char *)1...
 1.38  02-Jul-2003  simonb Use the terminal width to choose the default number of drives listed.

Suggested by matt green and (indirectly) enami tsugutomo.
 1.37  02-Jul-2003  simonb Pinch code from vmstat to get the number of lines of the terminal, and
show the header once per screen instead of fixed at every 22 lines.
 1.36  02-Jul-2003  simonb Bump the width of the MB/s and t/s fields and show only 3 drives by
default. The default display now fits in 80 columns, and looks much
better on modern systems.
 1.35  11-Jun-2003  drochner no need to #include <sys/dkstat.h>
 1.34  01-Mar-2003  enami - Account the number of lines consumed so that -xw displays header
frequently enough.
- As we are initializing dk_select to 0 (via dkinit), no need to check it.
- Re-order the code in display() to highlight the fact that -x is
exclusive with others.
- If user really specified some drives and none of them are found,
just bail out rather than falling back to default behaviour.
- Other misc. cosmetic changes while I'm here.
 1.33  01-Mar-2003  christos PR/20435: KOIE Hidetaka: iostat -x ignores drive selection.
 1.32  02-Nov-2002  enami ... and fix typos which makes wrong display.
 1.31  02-Nov-2002  enami Cosmetic changes.
 1.30  01-Nov-2002  simonb Print a newline between lines in -x mode.
 1.29  01-Nov-2002  mrg 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.
 1.28  18-Sep-2002  mycroft select() -> nanosleep()
 1.27  30-Jun-2002  sommerfeld Since the KERN_CP_TIME sysctl reports total clock ticks across all
cpus and hz is measured in ticks per cpu, divide tick count by ncpu to
determine elapsed time since last sample.

Fixes I/O rate deflation observed on multiprocessors.
 1.26  22-May-2002  simonb We don't need the code to discard setgid privileges if we aren't setgid!
 1.25  28-Jan-2002  simonb branches: 1.25.2;
Drop the setgid'ness now that ../../usr.bin/vmstat/dkstats.c uses
sysctls now.
 1.24  01-Dec-2000  simonb Remove extern variables and functions now declared in dkstats.h.
 1.23  30-Nov-2000  simonb ANSIfy.
 1.22  03-Jun-2000  thorpej Need to include <sys/sched.h> to get cp_time-related constants.
 1.21  29-May-2000  simonb Use " %2.0f" instead of "%3.0f" to print out the CPU percentages - this
way 100 in a column doesn't merge into the previous column.
 1.20  13-Sep-1999  tron branches: 1.20.6;
Don't unnecessarily check device names if "-x" is used.
 1.19  13-Sep-1999  tron Display all drives if "iostat -x <interval>" is used.
Fixes PR bin/8389 by Mattias Pantzare.
 1.18  27-Jun-1999  mjl Truncate disk names in header to 7 instead of 3 chars, we actually
have "raid0".
 1.17  27-Aug-1998  lukem branches: 1.17.2;
in -x, print MB/s two 2 decimal places. noted by enami@netbsd.org
 1.16  27-Aug-1998  enami add -x in usage.
 1.15  25-Aug-1998  lukem * implement -x; extended disk statistics. option inspired by solaris' iostat.
* fix a few typos
* a bit of KNF and egcs cleanup
* add a HISTORY (hopefully correct)
 1.14  19-Jul-1998  drochner adapt to changed dkinit() in ../../usr.bin/vmstat/dkstats.c
 1.13  05-Jul-1998  mrg KNF.
 1.12  17-Oct-1997  lukem WARNSify
 1.11  17-Oct-1997  mrg merge lite-2
 1.10  25-Oct-1996  scottr `Kb' means kilobits, `Mb' means megabits. Since we're talking about bytes,
not bits, use the uppercase `B' when reporting statistics, and be explicit
about it where appropriate. Noticed by J.T.
 1.9  10-May-1996  thorpej New userland code to read the statistics kept by the NetBSD generic
disk framework, from John M. Vinopal <banshee@gabriella.resort.com>
 1.8  28-Nov-1995  thorpej New-style RCS ids.
 1.7  18-Jan-1995  mycroft Add a column header for CP_INTR.
 1.6  14-May-1994  cgd clean up import. that was weird.
 1.5  16-Mar-1994  cgd isa device configuration changed, and the tables got killed/renamed.
fix from Jarle Greipsland <jarle@darling.idt.unit.no>.
 1.4  06-Dec-1993  cgd __386BSD__ -> i386; this file might break for m68k because of ifdefs...
 1.3  01-Aug-1993  mycroft Add RCS identifiers.
 1.2  04-May-1993  deraadt iostat and vmstat being taught about drives..
 1.1  09-Apr-1993  cgd branches: 1.1.1;
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
 1.1.1.2  29-Apr-1995  mrg 4.4BSD-Lite2
 1.1.1.1  14-May-1994  cgd new iostat from Lite
 1.17.2.1  20-Nov-1999  he Pull up revision 1.18 (requested by mjl):
Truncate device names at 7, not at 3 chars (so raid0 et al comes
out ok).
 1.20.6.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.25.2.1  30-Jun-2002  lukem Pull up revision 1.27 (requested by sommerfeld in ticket #406):
Since the KERN_CP_TIME sysctl reports total clock ticks across all
cpus and hz is measured in ticks per cpu, divide tick count by ncpu to
determine elapsed time since last sample.
Fixes I/O rate deflation observed on multiprocessors.
 1.51.12.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.52.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.57.2.1  17-Feb-2011  bouyer Sync with HEAD
 1.60.18.1  10-Aug-2014  tls Rebase.
 1.60.8.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.61.2.1  08-Nov-2015  riz Pull up following revision(s) (requested by mrg in ticket #1016):
usr.sbin/iostat/iostat.c: revision 1.62
usr.sbin/iostat/iostat.c: revision 1.63
usr.sbin/iostat/iostat.8: revision 1.24
support fnmatch(3) patterns for disknames. eg, "iostat wd*" works now.
update the default disk number selection to note that it uses the current
terminal size to fit disks, not hard coded 4.
extend the "tout" column to 5 characters, it's really common on a modern
machine to have eg, build output way more than 9999 chars/sec.
this doesn't affect the default disk list on an 80-char wide screen.
 1.63.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.63.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.64.4.1  25-Jul-2017  snj Pull up following revision(s) (requested by mlelstv in ticket #138):
usr.bin/systat/iostat.c: revision 1.38
usr.bin/systat/vmstat.c: revision 1.82
usr.bin/vmstat/drvstats.c: revision 1.11
usr.bin/vmstat/drvstats.h: revision 1.5
usr.bin/vmstat/vmstat.c: revision 1.217
usr.sbin/iostat/iostat.c: revision 1.65
Use I/O timestamps to compute disk statistics for better precision.
Disk statistics are collected in a fixed size array, that got corrupted
when a disk was detached. Adapt by skipping entries of detached disks
and detect reused disknames at the array end.
--
Use I/O timestamps to compute disk statistics for better precisison.
 1.66.2.1  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.67.4.1  01-Apr-2023  martin Pull up following revision(s) (requested by kre in ticket #1626):

usr.sbin/iostat/iostat.c: revision 1.68

Fix processing of the archaic arg format (BACKWARD_COMPATIBILITY) so it
doesn't repeat the processing every iteration. Repeatedly seeing the wait
interval does no harm, but setting the iteration count (reps) over and
over again rather defeats its purpose.

RSS XML Feed