mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Add -y option to zpool iostat
sysstat's iostat omits the first report when the -y option is used. This patch adds that functionality and omits the first report with statistics since system boot. Signed-off-by: Hajo Möller <dasjoe@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3439
This commit is contained in:
parent
8e70975f90
commit
410921241d
@ -236,8 +236,8 @@ get_usage(zpool_help_t idx) {
|
|||||||
"[-R root] [-F [-n]]\n"
|
"[-R root] [-F [-n]]\n"
|
||||||
"\t <pool | id> [newpool]\n"));
|
"\t <pool | id> [newpool]\n"));
|
||||||
case HELP_IOSTAT:
|
case HELP_IOSTAT:
|
||||||
return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
|
return (gettext("\tiostat [-v] [-T d|u] [-y] [pool] ... "
|
||||||
"[count]]\n"));
|
"[interval [count]]\n"));
|
||||||
case HELP_LABELCLEAR:
|
case HELP_LABELCLEAR:
|
||||||
return (gettext("\tlabelclear [-f] <vdev>\n"));
|
return (gettext("\tlabelclear [-f] <vdev>\n"));
|
||||||
case HELP_LIST:
|
case HELP_LIST:
|
||||||
@ -2817,10 +2817,11 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
unsigned long interval = 0, count = 0;
|
unsigned long interval = 0, count = 0;
|
||||||
zpool_list_t *list;
|
zpool_list_t *list;
|
||||||
boolean_t verbose = B_FALSE;
|
boolean_t verbose = B_FALSE;
|
||||||
|
boolean_t omit_since_boot = B_FALSE;
|
||||||
iostat_cbdata_t cb;
|
iostat_cbdata_t cb;
|
||||||
|
|
||||||
/* check options */
|
/* check options */
|
||||||
while ((c = getopt(argc, argv, "T:v")) != -1) {
|
while ((c = getopt(argc, argv, "T:vy")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'T':
|
case 'T':
|
||||||
get_timestamp_arg(*optarg);
|
get_timestamp_arg(*optarg);
|
||||||
@ -2828,6 +2829,9 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
case 'v':
|
case 'v':
|
||||||
verbose = B_TRUE;
|
verbose = B_TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'y':
|
||||||
|
omit_since_boot = B_TRUE;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||||
optopt);
|
optopt);
|
||||||
@ -2867,11 +2871,16 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
cb.cb_namewidth = 0;
|
cb.cb_namewidth = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pool_list_update(list);
|
|
||||||
|
|
||||||
if ((npools = pool_list_count(list)) == 0)
|
if ((npools = pool_list_count(list)) == 0)
|
||||||
(void) fprintf(stderr, gettext("no pools available\n"));
|
(void) fprintf(stderr, gettext("no pools available\n"));
|
||||||
else {
|
else {
|
||||||
|
/*
|
||||||
|
* If this is the first iteration and -y was supplied
|
||||||
|
* we skip any printing.
|
||||||
|
*/
|
||||||
|
boolean_t skip = (omit_since_boot &&
|
||||||
|
cb.cb_iteration == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Refresh all statistics. This is done as an
|
* Refresh all statistics. This is done as an
|
||||||
* explicit step before calculating the maximum name
|
* explicit step before calculating the maximum name
|
||||||
@ -2893,12 +2902,18 @@ zpool_do_iostat(int argc, char **argv)
|
|||||||
print_timestamp(timestamp_fmt);
|
print_timestamp(timestamp_fmt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If it's the first time, or verbose mode, print the
|
* If it's the first time and we're not skipping it,
|
||||||
* header.
|
* or either skip or verbose mode, print the header.
|
||||||
*/
|
*/
|
||||||
if (++cb.cb_iteration == 1 || verbose)
|
if ((++cb.cb_iteration == 1 && !skip) ||
|
||||||
|
(skip != verbose))
|
||||||
print_iostat_header(&cb);
|
print_iostat_header(&cb);
|
||||||
|
|
||||||
|
if (skip) {
|
||||||
|
(void) sleep(interval);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
(void) pool_list_iter(list, B_FALSE, print_iostat, &cb);
|
(void) pool_list_iter(list, B_FALSE, print_iostat, &cb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -94,7 +94,7 @@ zpool \- configures ZFS storage pools
|
|||||||
|
|
||||||
.LP
|
.LP
|
||||||
.nf
|
.nf
|
||||||
\fBzpool iostat\fR [\fB-T\fR d | u ] [\fB-v\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]
|
\fBzpool iostat\fR [\fB-T\fR d | u ] [\fB-v\fR] [\fB-y\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
.LP
|
.LP
|
||||||
@ -1608,7 +1608,7 @@ Allows a pool to import when there is a missing log device.
|
|||||||
.ne 2
|
.ne 2
|
||||||
.mk
|
.mk
|
||||||
.na
|
.na
|
||||||
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-v\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]\fR
|
\fB\fBzpool iostat\fR [\fB-T\fR \fBd\fR | \fBu\fR] [\fB-v\fR] [\fB-y\fR] [\fIpool\fR] ... [\fIinterval\fR[\fIcount\fR]]\fR
|
||||||
.ad
|
.ad
|
||||||
.sp .6
|
.sp .6
|
||||||
.RS 4n
|
.RS 4n
|
||||||
@ -1637,6 +1637,17 @@ Specify \fBu\fR for a printed representation of the internal representation of t
|
|||||||
Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within the pool, in addition to the pool-wide statistics.
|
Verbose statistics. Reports usage statistics for individual \fIvdevs\fR within the pool, in addition to the pool-wide statistics.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
.sp
|
||||||
|
.ne 2
|
||||||
|
.mk
|
||||||
|
.na
|
||||||
|
\fB\fB-y\fR\fR
|
||||||
|
.ad
|
||||||
|
.RS 12n
|
||||||
|
.rt
|
||||||
|
Omit statistics since boot. Normally the first line of output reports the statistics since boot. This option suppresses that first line of output.
|
||||||
|
.RE
|
||||||
|
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.sp
|
.sp
|
||||||
|
Loading…
Reference in New Issue
Block a user