diff options
author | Hajo Möller <[email protected]> | 2015-05-24 20:22:55 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-06-17 10:39:20 -0700 |
commit | 410921241d00d9e6e48d6e544ab5fbf2f642a72d (patch) | |
tree | 6ebb9a8f37e8fbf598b75f91251fa045584a0d6a /cmd/zpool/zpool_main.c | |
parent | 8e70975f905935df2a68fb242570056035a52948 (diff) |
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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3439
Diffstat (limited to 'cmd/zpool/zpool_main.c')
-rw-r--r-- | cmd/zpool/zpool_main.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 5c28e8bb1..fd1e8284a 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -236,8 +236,8 @@ get_usage(zpool_help_t idx) { "[-R root] [-F [-n]]\n" "\t <pool | id> [newpool]\n")); case HELP_IOSTAT: - return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval " - "[count]]\n")); + return (gettext("\tiostat [-v] [-T d|u] [-y] [pool] ... " + "[interval [count]]\n")); case HELP_LABELCLEAR: return (gettext("\tlabelclear [-f] <vdev>\n")); case HELP_LIST: @@ -2817,10 +2817,11 @@ zpool_do_iostat(int argc, char **argv) unsigned long interval = 0, count = 0; zpool_list_t *list; boolean_t verbose = B_FALSE; + boolean_t omit_since_boot = B_FALSE; iostat_cbdata_t cb; /* check options */ - while ((c = getopt(argc, argv, "T:v")) != -1) { + while ((c = getopt(argc, argv, "T:vy")) != -1) { switch (c) { case 'T': get_timestamp_arg(*optarg); @@ -2828,6 +2829,9 @@ zpool_do_iostat(int argc, char **argv) case 'v': verbose = B_TRUE; break; + case 'y': + omit_since_boot = B_TRUE; + break; case '?': (void) fprintf(stderr, gettext("invalid option '%c'\n"), optopt); @@ -2867,12 +2871,17 @@ zpool_do_iostat(int argc, char **argv) cb.cb_namewidth = 0; for (;;) { - pool_list_update(list); - if ((npools = pool_list_count(list)) == 0) (void) fprintf(stderr, gettext("no pools available\n")); 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 * explicit step before calculating the maximum name * width, so that any * configuration changes are @@ -2893,12 +2902,18 @@ zpool_do_iostat(int argc, char **argv) print_timestamp(timestamp_fmt); /* - * If it's the first time, or verbose mode, print the - * header. + * If it's the first time and we're not skipping it, + * 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); + if (skip) { + (void) sleep(interval); + continue; + } + (void) pool_list_iter(list, B_FALSE, print_iostat, &cb); /* |