fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov * Copyright (c) 2016 by Delphix. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Routines needed by more than one client of libzpool.
fa9e4066f08beec538e775443c5be79dd423fcabahrens while (n >= 1024) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (index == 0) {
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwickshow_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent)
fa9e4066f08beec538e775443c5be79dd423fcabahrens char rops[6], wops[6], rbytes[6], wbytes[6], rerr[6], werr[6], cerr[6];
fa9e4066f08beec538e775443c5be79dd423fcabahrens " capacity operations bandwidth ---- errors ----\n");
fa9e4066f08beec538e775443c5be79dd423fcabahrens "used avail read write read write read write cksum\n");
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_IS_LOG, &is_log);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling if (nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick (void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n",
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick indent + strlen(prefix) - 25 - (vs->vs_space ? 0 : 12),
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick vs->vs_space ? 6 : 0, vs->vs_space ? used : "",
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick vs->vs_space ? 6 : 0, vs->vs_space ? avail : "",
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick if (nvlist_lookup_nvlist_array(nv, ctype, &child, &children) != 0)
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (c = 0; c < children; c++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (nvlist_lookup_string(cnv, ZPOOL_CONFIG_PATH, &cname) &&
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_lookup_string(cnv, ZPOOL_CONFIG_TYPE, &cname))
99653d4ee642c6528e88224f12409a5f23060994eschrock if (nvlist_lookup_uint64(cnv, ZPOOL_CONFIG_NPARITY, &np) == 0)
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick show_vdev_stats(tname, ctype, cnv, indent + 2);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick VERIFY(spa_get_stats(spa_name(spa), &config, NULL, 0) == 0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens VERIFY(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
0373e76b3c3643df49ef3483e0f293fdea61d8c6bonwick VERIFY(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick show_vdev_stats(name, ZPOOL_CONFIG_CHILDREN, nvroot, 0);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick show_vdev_stats(NULL, ZPOOL_CONFIG_L2CACHE, nvroot, 0);
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick show_vdev_stats(NULL, ZPOOL_CONFIG_SPARES, nvroot, 0);
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov * Sets given global variable in libzpool to given unsigned 32-bit value.
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov * arg: "<variable>=<value>"
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov * On big endian systems changing a 64-bit variable would set the high
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov * 32 bits instead of the low 32 bits, which could cause unexpected
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov fprintf(stderr, "Setting global variables is only supported on "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov fprintf(stderr, "Value for global variable '%s' must "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov fprintf(stderr, "Global variable '%s' does not exist "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov fprintf(stderr, "Failed to open libzpool.so to set global "
0e60744c982adecd0a1f146f5637475d07ab1069Pavel Zakharov "variable\n");