aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/Makefile3
-rw-r--r--usr.sbin/iostat/Makefile.depend3
-rw-r--r--usr.sbin/iostat/iostat.8102
-rw-r--r--usr.sbin/iostat/iostat.c56
4 files changed, 91 insertions, 73 deletions
diff --git a/usr.sbin/iostat/Makefile b/usr.sbin/iostat/Makefile
index 4d74fe163d0b..7ea659db5e1c 100644
--- a/usr.sbin/iostat/Makefile
+++ b/usr.sbin/iostat/Makefile
@@ -1,6 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
-
PROG= iostat
MAN= iostat.8
diff --git a/usr.sbin/iostat/Makefile.depend b/usr.sbin/iostat/Makefile.depend
index 70e72f3ef71d..3b8b50f9f6bf 100644
--- a/usr.sbin/iostat/Makefile.depend
+++ b/usr.sbin/iostat/Makefile.depend
@@ -1,15 +1,12 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libdevstat \
- lib/libelf \
lib/libkvm \
lib/msun \
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index 323e77ef6447..11f0ef6fbeb6 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD$
-.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -54,9 +52,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
-.\"
-.Dd May 22, 2015
+.Dd November 26, 2023
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -66,7 +62,7 @@
statistics
.Sh SYNOPSIS
.Nm
-.Op Fl CdhIKoTxz?\&
+.Op Fl CdhIKoTxz
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl n Ar devs
@@ -85,25 +81,18 @@ The
utility displays kernel
.Tn I/O
statistics on terminal, device and cpu operations.
-The first statistics that are printed are averaged over the system uptime.
+The first statistics that are printed are averaged over the system uptime
+(unless
+.Fl I
+is specified).
+Any references to repetitions in this man page implicitly include the first
+statistics output.
To get information about the current activity, a suitable wait time should
be specified, so that the subsequent sets of printed statistics will be
averaged over that time.
.Pp
The options are as follows:
.Bl -tag -width flag
-.It Fl c
-Repeat the display
-.Ar count
-times.
-If no repeat
-.Ar count
-is specified, the default depends on whether
-.Fl w
-is specified.
-With
-.Fl w
-the default repeat count is infinity, otherwise it is 1.
.It Fl C
Display CPU statistics.
This is on by default, unless
@@ -111,6 +100,15 @@ This is on by default, unless
or
.Fl x
is specified.
+.It Fl c
+Repeat the display
+.Ar count
+times.
+If
+.Fl c
+is not specified and a wait interval is specified,
+the default repeat count is infinity.
+If no wait interval is specified, the default repeat count is 1.
.It Fl d
Display only device statistics.
If this flag is turned on, only device statistics will be displayed, unless
@@ -132,24 +130,27 @@ per measurement cycle.
Display total statistics for a given time period, rather than average
statistics for each second during that time period.
.It Fl K
-In the blocks transferred display (-o), display block count in kilobytes rather
-then the device native block size.
+In the old-style blocks transferred display
+.Po Fl I
+and
+.Fl o Pc ,
+display block count in kilobytes rather than the device native block size.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
.Dq Pa /dev/kmem .
+.It Fl N
+Extract the name list from the specified system instead of the default
+.Dq Pa /boot/kernel/kernel .
.It Fl n
Display up to
.Ar devs
number of devices.
The
.Nm
-utility will display fewer devices if there are not
+utility will display fewer devices if there are less than
.Ar devs
devices present.
-.It Fl N
-Extract the name list from the specified system instead of the default
-.Dq Pa /boot/kernel/kernel .
.It Fl o
Display old-style
.Nm
@@ -160,6 +161,13 @@ If
.Fl I
is specified, total blocks/sectors, total transfers, and
milliseconds per seek are displayed.
+.It Fl T
+Display TTY statistics.
+This is on by default, unless
+.Fl d
+or
+.Fl x
+is specified.
.It Fl t
Specify which types of devices to display.
There are three different categories of devices:
@@ -201,6 +209,8 @@ Floppy devices
Integrated Drive Electronics devices
.It SCSI
Small Computer System Interface devices
+.It NVME
+NVM Express Interface devices
.It other
Any other device interface
.El
@@ -215,7 +225,7 @@ Passthrough devices
The user must specify at least one device type, and may specify at most
one device type from each category.
Multiple device types in a single device type statement must be separated by
-commas.
+commas and are ANDed together.
.Pp
Any number of
.Fl t
@@ -229,21 +239,16 @@ Any device that fully matches any
argument will be included in the
.Nm
output, up to the number of devices that can be displayed in
-80 columns, or the maximum number of devices specified by the user.
-.It Fl T
-Display TTY statistics.
-This is on by default, unless
-.Fl d
-or
-.Fl x
-is specified.
+80 columns, or the maximum number of devices
+.Pq Fl n
+specified by the user.
.It Fl w
Pause
.Ar wait
seconds between each display.
-If no
-.Ar wait
-interval is specified, the default is 1 second.
+If
+.Fl w
+is not specified, the default interval is 1 second.
.Pp
The
.Nm
@@ -269,8 +274,6 @@ is also specified to enable the display of CPU or TTY statistics.
If
.Fl x
is specified, omit lines for devices with no activity.
-.It Fl ?\&
-Display a usage statement and exit.
.El
.Pp
The
@@ -520,3 +523,24 @@ The use of
as a debugging tool for crash dumps is probably limited because there is
currently no way to get statistics that only cover the time immediately before
the crash.
+.Pp
+Each
+.Ar drives
+argument is passed to
+.Fn isdigit .
+If
+.Fn isdigit
+returns true,
+.Nm
+switches into an undocumented traditional syntax and subsequent arguments,
+if any, will not be interpreted as drive names.
+This behavior collides with the one documented in this man page and prevents
+specifying drive names starting with a number.
+E.g., the following
+.Bd -literal -offset indent
+iostat ada0 ada1 2 3 cd0
+.Ed
+.Pp
+This document's use of
+.Dq device type
+is misleading.
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 9140bf10ef07..ec18f4fd35b3 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -26,8 +26,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
@@ -149,7 +147,7 @@ static int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
static int xflag = 0, zflag = 0;
/* local function declarations */
-static void usage(void);
+static void usage(void) __dead2;
static void needhdr(int signo);
static void needresize(int signo);
static void needreturn(int signo);
@@ -170,16 +168,17 @@ usage(void)
* This isn't mentioned in the man page, or the usage statement,
* but it is supported.
*/
- fprintf(stderr, "usage: iostat [-CdhIKoTxz?] [-c count] [-M core]"
+ fprintf(stderr, "usage: iostat [-CdhIKoTxz] [-c count] [-M core]"
" [-n devs] [-N system]\n"
"\t [-t type,if,pass] [-w wait] [drives]\n");
+ exit(1);
}
int
main(int argc, char **argv)
{
int c, i;
- int tflag = 0, hflag = 0, cflag = 0, wflag = 0, nflag = 0;
+ int hflag = 0, cflag = 0, wflag = 0, nflag = 0;
int count = 0, waittime = 0;
char *memf = NULL, *nlistf = NULL;
struct devstat_match *matches;
@@ -199,17 +198,17 @@ main(int argc, char **argv)
matches = NULL;
maxshowdevs = 3;
- while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:xz?")) != -1) {
- switch(c) {
+ while ((c = getopt(argc, argv, "Cc:dhIKM:N:n:oTt:w:xz")) != -1) {
+ switch (c) {
+ case 'C':
+ Cflag++;
+ break;
case 'c':
cflag++;
count = atoi(optarg);
if (count < 1)
errx(1, "count %d is < 1", count);
break;
- case 'C':
- Cflag++;
- break;
case 'd':
dflag++;
break;
@@ -225,6 +224,9 @@ main(int argc, char **argv)
case 'M':
memf = optarg;
break;
+ case 'N':
+ nlistf = optarg;
+ break;
case 'n':
nflag++;
maxshowdevs = atoi(optarg);
@@ -232,21 +234,17 @@ main(int argc, char **argv)
errx(1, "number of devices %d is < 0",
maxshowdevs);
break;
- case 'N':
- nlistf = optarg;
- break;
case 'o':
oflag++;
break;
+ case 'T':
+ Tflag++;
+ break;
case 't':
- tflag++;
if (devstat_buildmatch(optarg, &matches,
&num_matches) != 0)
errx(1, "%s", devstat_errbuf);
break;
- case 'T':
- Tflag++;
- break;
case 'w':
wflag++;
f = atof(optarg);
@@ -262,8 +260,6 @@ main(int argc, char **argv)
break;
default:
usage();
- exit(1);
- break;
}
}
@@ -616,7 +612,7 @@ main(int argc, char **argv)
}
if (xflag == 0 && Tflag > 0)
- printf("%4.0Lf %5.0Lf", cur.tk_nin / etime,
+ printf("%4.0Lf %5.0Lf ", cur.tk_nin / etime,
cur.tk_nout / etime);
devstats(hflag, etime, havelast);
@@ -735,7 +731,7 @@ phdr(void)
return;
if (Tflag > 0)
- (void)printf(" tty");
+ (void)printf(" tty ");
for (i = 0, printed=0;(i < num_devices) && (printed < maxshowdevs);i++){
int di;
if ((dev_select[i].selected != 0)
@@ -757,7 +753,7 @@ phdr(void)
(void)printf("\n");
if (Tflag > 0)
- (void)printf(" tin tout");
+ (void)printf(" tin tout ");
for (i=0, printed = 0;(i < num_devices) && (printed < maxshowdevs);i++){
if ((dev_select[i].selected != 0)
@@ -769,9 +765,9 @@ phdr(void)
(void)printf(" blk xfr msps ");
} else {
if (Iflag == 0)
- printf(" KB/t tps MB/s ");
+ printf("KB/t tps MB/s ");
else
- printf(" KB/t xfrs MB ");
+ printf("KB/t xfrs MB ");
}
printed++;
}
@@ -938,26 +934,30 @@ devstats(int perf_select, long double etime, int havelast)
msdig,
ms_per_transaction);
else
- printf("%4.1" PRIu64 "%4.1" PRIu64 "%5.*Lf ",
+ printf("%4" PRIu64 "%4" PRIu64 "%5.*Lf ",
total_blocks,
total_transfers,
msdig,
ms_per_transaction);
} else {
if (Iflag == 0)
- printf(" %4.*Lf %4.0Lf %5.*Lf ",
+ printf("%4.*Lf %5.0Lf %5.*Lf ",
kb_per_transfer >= 100 ? 0 : 1,
kb_per_transfer,
transfers_per_second,
- mb_per_second >= 1000 ? 0 : 1,
+ mb_per_second >= 1000 ? 0 :
+ (total_mb >= 100 ? 1 : 2),
mb_per_second);
else {
total_mb = total_bytes;
total_mb /= 1024 * 1024;
- printf(" %4.1Lf %4.1" PRIu64 " %5.2Lf ",
+ printf("%4.*Lf %5" PRIu64 " %5.*Lf ",
+ kb_per_transfer >= 100 ? 0 : 1,
kb_per_transfer,
total_transfers,
+ total_mb >= 1000 ? 0 :
+ (total_mb >= 100 ? 1 : 2),
total_mb);
}
}