Permalink
Browse files

zpool iostat should print headers when terminal fills

When zpool iostat fills terminal headers should be printed again.
zpool iostat -n will supress this.

Signed-off-by: Damian Wojsław <damian@wojslaw.pl>
Closes: #8235
Issue: #8235
  • Loading branch information...
madwizard committed Jan 10, 2019
1 parent 8bd2a28 commit 650e63e2a04c74ec5f39e9b57d718905277ea98a
Showing with 26 additions and 7 deletions.
  1. +16 −3 cmd/zpool/zpool_main.c
  2. +10 −4 man/man8/zpool.8
@@ -345,7 +345,7 @@ get_usage(zpool_help_t idx)
return (gettext("\tiostat [[[-c [script1,script2,...]"
"[-lq]]|[-rw]] [-T d | u] [-ghHLpPvy]\n"
"\t [[pool ...]|[pool vdev ...]|[vdev ...]]"
" [interval [count]]\n"));
" [[-n] interval [count]]\n"));
case HELP_LABELCLEAR:
return (gettext("\tlabelclear [-f] <vdev>\n"));
case HELP_LIST:
@@ -4917,6 +4917,7 @@ get_namewidth_iostat(zpool_handle_t *zhp, void *data)
* -w Display latency histograms
* -r Display request size histogram
* -T Display a timestamp in date(1) or Unix format
* -n>·Only print headers once
*
* This command can be tricky because we want to be able to deal with pool
* creation/destruction as well as vdev configuration changes. The bulk of this
@@ -4932,6 +4933,8 @@ zpool_do_iostat(int argc, char **argv)
int npools;
float interval = 0;
unsigned long count = 0;
struct winsize win;
int winheight = 24;
zpool_list_t *list;
boolean_t verbose = B_FALSE;
boolean_t latency = B_FALSE, l_histo = B_FALSE, rq_histo = B_FALSE;
@@ -4940,6 +4943,7 @@ zpool_do_iostat(int argc, char **argv)
boolean_t guid = B_FALSE;
boolean_t follow_links = B_FALSE;
boolean_t full_name = B_FALSE;
boolean_t headers_once = B_FALSE;
iostat_cbdata_t cb = { 0 };
char *cmd = NULL;

@@ -4950,7 +4954,7 @@ zpool_do_iostat(int argc, char **argv)
uint64_t unsupported_flags;

/* check options */
while ((c = getopt(argc, argv, "c:gLPT:vyhplqrwH")) != -1) {
while ((c = getopt(argc, argv, "c:gLPT:vyhplqrwnH")) != -1) {
switch (c) {
case 'c':
if (cmd != NULL) {
@@ -5013,6 +5017,9 @@ zpool_do_iostat(int argc, char **argv)
case 'y':
omit_since_boot = B_TRUE;
break;
case 'n':
headers_once = B_TRUE;
break;
case 'h':
usage(B_FALSE);
break;
@@ -5174,6 +5181,10 @@ zpool_do_iostat(int argc, char **argv)
return (1);
}


if (ioctl(1, TIOCGWINSZ, &win) != -1 && win.ws_row > 0)
winheight = win.ws_row;

for (;;) {
if ((npools = pool_list_count(list)) == 0)
(void) fprintf(stderr, gettext("no pools available\n"));
@@ -5222,7 +5233,9 @@ zpool_do_iostat(int argc, char **argv)
* every vdev, so skip this for histograms.
*/
if (((++cb.cb_iteration == 1 && !skip) ||
(skip != verbose)) &&
(skip != verbose) ||
(!headers_once &&
(cb.cb_iteration%winheight) == 0)) &&
(!(cb.cb_flags & IOS_ANYHISTO_M)) &&
!cb.cb_scripted)
print_iostat_header(&cb);
@@ -123,7 +123,7 @@
.Cm iostat
.Op Oo Oo Fl c Ar SCRIPT Oc Oo Fl lq Oc Oc Ns | Ns Fl rw
.Op Fl T Sy u Ns | Ns Sy d
.Op Fl ghHLpPvy
.Op Fl ghHLpPvyn
.Oo Oo Ar pool Ns ... Oc Ns | Ns Oo Ar pool vdev Ns ... Oc Ns | Ns Oo Ar vdev Ns ... Oc Oc
.Op Ar interval Op Ar count
.Nm
@@ -1631,7 +1631,7 @@ with no flags on the relevant target devices.
.Cm iostat
.Op Oo Oo Fl c Ar SCRIPT Oc Oo Fl lq Oc Oc Ns | Ns Fl rw
.Op Fl T Sy u Ns | Ns Sy d
.Op Fl ghHLpPvy
.Op Fl ghHLpPvyn
.Oo Oo Ar pool Ns ... Oc Ns | Ns Oo Ar pool vdev Ns ... Oc Ns | Ns Oo Ar vdev Ns ... Oc Oc
.Op Ar interval Op Ar count
.Xc
@@ -1643,7 +1643,10 @@ When given an
.Ar interval ,
the statistics are printed every
.Ar interval
seconds until ^C is pressed. If count is specified, the command exits
seconds until ^C is pressed. If
.Fl n
flag is enabled headers are printed only once, otherwise they are
printed every time screen fills. If count is specified, the command exits
after count reports are printed. The first report printed is always
the statistics since boot regardless of whether
.Ar interval
@@ -1760,12 +1763,15 @@ pool, in addition to the pool-wide statistics.
Omit statistics since boot.
Normally the first line of output reports the statistics since boot.
This option suppresses that first line of output.
.It Fl n
Print headers only once when passed
.Ar interval
.It Fl w
Display latency histograms:
.Pp
.Ar total_wait :
Total IO time (queuing + disk IO time).
.Ar disk_wait :
.Ar disk_wait
Disk IO time (time reading/writing the disk).
.Ar syncq_wait :
Amount of time IO spent in synchronous priority queues. Does not include

0 comments on commit 650e63e

Please sign in to comment.