/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Frederik Wessels. All rights reserved.
*/
#include <assert.h>
return;
for (c = 0; c < children; c++) {
- uint64_t ishole = B_FALSE;
+ uint64_t ishole = B_FALSE, islog = B_FALSE;
- if (nvlist_lookup_uint64(newchild[c],
- ZPOOL_CONFIG_IS_HOLE, &ishole) == 0 && ishole)
+ (void) nvlist_lookup_uint64(newchild[c], ZPOOL_CONFIG_IS_HOLE,
+ &ishole);
+
+ (void) nvlist_lookup_uint64(newchild[c], ZPOOL_CONFIG_IS_LOG,
+ &islog);
+
+ if (ishole || islog)
continue;
vname = zpool_vdev_name(g_zfs, zhp, newchild[c], B_FALSE);
}
/*
+ * Log device section
+ */
+
+ if (num_logs(newnv) > 0) {
+ (void) printf("%-*s - - - - - "
+ "-\n", cb->cb_namewidth, "logs");
+
+ for (c = 0; c < children; c++) {
+ uint64_t islog = B_FALSE;
+ (void) nvlist_lookup_uint64(newchild[c],
+ ZPOOL_CONFIG_IS_LOG, &islog);
+
+ if (islog) {
+ vname = zpool_vdev_name(g_zfs, zhp, newchild[c],
+ B_FALSE);
+ print_vdev_stats(zhp, vname, oldnv ?
+ oldchild[c] : NULL, newchild[c],
+ cb, depth + 2);
+ free(vname);
+ }
+ }
+
+ }
+
+ /*
* Include level 2 ARC devices in iostat output
*/
if (nvlist_lookup_nvlist_array(newnv, ZPOOL_CONFIG_L2CACHE,
return (0);
}
+static int
+get_columns(void)
+{
+ struct winsize ws;
+ int columns = 80;
+ int error;
+
+ if (isatty(STDOUT_FILENO)) {
+ error = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
+ if (error == 0)
+ columns = ws.ws_col;
+ } else {
+ columns = 999;
+ }
+
+ return columns;
+}
+
int
get_namewidth(zpool_handle_t *zhp, void *data)
{
iostat_cbdata_t *cb = data;
nvlist_t *config, *nvroot;
+ int columns;
if ((config = zpool_get_config(zhp, NULL)) != NULL) {
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
if (!cb->cb_verbose)
cb->cb_namewidth = strlen(zpool_get_name(zhp));
else
- cb->cb_namewidth = max_width(zhp, nvroot, 0, 0);
+ cb->cb_namewidth = max_width(zhp, nvroot, 0,
+ cb->cb_namewidth);
}
/*
- * The width must fall into the range [10,38]. The upper limit is the
- * maximum we can have and still fit in 80 columns.
+ * The width must be at least 10, but may be as large as the
+ * column width - 42 so that we can still fit in one line.
*/
+ columns = get_columns();
+
if (cb->cb_namewidth < 10)
cb->cb_namewidth = 10;
- if (cb->cb_namewidth > 38)
- cb->cb_namewidth = 38;
+ if (cb->cb_namewidth > columns - 42)
+ cb->cb_namewidth = columns - 42;
return (0);
}