View | Details | Raw Unified | Return to bug 229365
Collapse All | Expand All

(-)cddl/contrib/opensolaris/cmd/zpool/zpool_main.c (-28 / +62 lines)
Lines 233-239 Link Here
233
		    "[-R root] [-F [-n]]\n"
233
		    "[-R root] [-F [-n]]\n"
234
		    "\t    <pool | id> [newpool]\n"));
234
		    "\t    <pool | id> [newpool]\n"));
235
	case HELP_IOSTAT:
235
	case HELP_IOSTAT:
236
		return (gettext("\tiostat [-v] [-T d|u] [pool] ... [interval "
236
		return (gettext("\tiostat [-Hpv] [-T d|u] [pool] ... [interval "
237
		    "[count]]\n"));
237
		    "[count]]\n"));
238
	case HELP_LABELCLEAR:
238
	case HELP_LABELCLEAR:
239
		return (gettext("\tlabelclear [-f] <vdev>\n"));
239
		return (gettext("\tlabelclear [-f] <vdev>\n"));
Lines 2324-2329 Link Here
2324
	int cb_namewidth;
2324
	int cb_namewidth;
2325
	int cb_iteration;
2325
	int cb_iteration;
2326
	zpool_list_t *cb_list;
2326
	zpool_list_t *cb_list;
2327
	boolean_t cb_literal;
2328
	boolean_t cb_scripted;
2327
} iostat_cbdata_t;
2329
} iostat_cbdata_t;
2328
static void
2330
static void
Lines 2331-2336 Link Here
2331
{
2333
{
2332
	int i = 0;
2334
	int i = 0;
2335
	if (cb->cb_scripted || cb->cb_literal)
2336
		return;
2337
2333
	for (i = 0; i < cb->cb_namewidth; i++)
2338
	for (i = 0; i < cb->cb_namewidth; i++)
2334
		(void) printf("-");
2339
		(void) printf("-");
2335
	(void) printf("  -----  -----  -----  -----  -----  -----\n");
2340
	(void) printf("  -----  -----  -----  -----  -----  -----\n");
Lines 2339-2349 Link Here
2339
static void
2344
static void
2340
print_iostat_header(iostat_cbdata_t *cb)
2345
print_iostat_header(iostat_cbdata_t *cb)
2341
{
2346
{
2342
	(void) printf("%*s     capacity     operations    bandwidth\n",
2347
	if (cb->cb_scripted)
2343
	    cb->cb_namewidth, "");
2348
		return;
2344
	(void) printf("%-*s  alloc   free   read  write   read  write\n",
2349
2345
	    cb->cb_namewidth, "pool");
2350
	if (cb->cb_literal) {
2346
	print_iostat_separator(cb);
2351
		(void) printf("pool/dev\talloc\tfree\trops\twops\trbytes\twbytes\n");
2352
	} else {
2353
		(void) printf("%*s     capacity     operations    bandwidth\n",
2354
		    cb->cb_namewidth, "");
2355
		(void) printf("%-*s  alloc   free   read  write   read  write\n",
2356
		    cb->cb_namewidth, "pool");
2357
		print_iostat_separator(cb);
2358
	}
2347
}
2359
}
2348
/*
2360
/*
Lines 2350-2361 Link Here
2350
 * Display a single statistic.
2362
 * Display a single statistic.
2351
 */
2363
 */
2352
static void
2364
static void
2353
print_one_stat(uint64_t value)
2365
print_one_stat(uint64_t value, iostat_cbdata_t *cb)
2354
{
2366
{
2355
	char buf[64];
2367
	char buf[64];
2356
2368
2357
	zfs_nicenum(value, buf, sizeof (buf));
2369
	if (cb->cb_literal) {
2358
	(void) printf("  %5s", buf);
2370
		(void) printf("\t%lu", value);
2371
	} else {
2372
		zfs_nicenum(value, buf, sizeof (buf));
2373
		(void) printf("  %5s", buf);
2374
	}
2359
}
2375
}
2360
/*
2376
/*
Lines 2385-2395 Link Here
2385
	verify(nvlist_lookup_uint64_array(newnv, ZPOOL_CONFIG_VDEV_STATS,
2401
	verify(nvlist_lookup_uint64_array(newnv, ZPOOL_CONFIG_VDEV_STATS,
2386
	    (uint64_t **)&newvs, &c) == 0);
2402
	    (uint64_t **)&newvs, &c) == 0);
2387
	if (strlen(name) + depth > cb->cb_namewidth)
2403
	if (cb->cb_literal) {
2388
		(void) printf("%*s%s", depth, "", name);
2404
		(void) printf("%.*s%s", depth, "::::::", name);
2389
	else
2405
	} else {
2390
		(void) printf("%*s%s%*s", depth, "", name,
2406
		if (strlen(name) + depth > cb->cb_namewidth)
2391
		    (int)(cb->cb_namewidth - strlen(name) - depth), "");
2407
			(void) printf("%*s%s", depth, "", name);
2408
		else
2409
			(void) printf("%*s%s%*s", depth, "", name,
2410
			    (int)(cb->cb_namewidth - strlen(name) - depth), "");
2411
	}
2392
	tdelta = newvs->vs_timestamp - oldvs->vs_timestamp;
2412
	tdelta = newvs->vs_timestamp - oldvs->vs_timestamp;
Lines 2398-2422 Link Here
2398
	else
2418
	else
2399
		scale = (double)NANOSEC / tdelta;
2419
		scale = (double)NANOSEC / tdelta;
2420
	if (cb->cb_literal)
2421
		scale = 1.0;
2422
2400
	/* only toplevel vdevs have capacity stats */
2423
	/* only toplevel vdevs have capacity stats */
2401
	if (newvs->vs_space == 0) {
2424
	if (newvs->vs_space == 0) {
2402
		(void) printf("      -      -");
2425
		if (cb->cb_literal)
2426
			(void) printf("\t-\t-");
2427
		else
2428
			(void) printf("      -      -");
2403
	} else {
2429
	} else {
2404
		print_one_stat(newvs->vs_alloc);
2430
		print_one_stat(newvs->vs_alloc, cb);
2405
		print_one_stat(newvs->vs_space - newvs->vs_alloc);
2431
		print_one_stat(newvs->vs_space - newvs->vs_alloc, cb);
2406
	}
2432
	}
2407
	print_one_stat((uint64_t)(scale * (newvs->vs_ops[ZIO_TYPE_READ] -
2433
	print_one_stat((uint64_t)(scale * (newvs->vs_ops[ZIO_TYPE_READ] -
2408
	    oldvs->vs_ops[ZIO_TYPE_READ])));
2434
	    oldvs->vs_ops[ZIO_TYPE_READ])), cb);
2409
	print_one_stat((uint64_t)(scale * (newvs->vs_ops[ZIO_TYPE_WRITE] -
2435
	print_one_stat((uint64_t)(scale * (newvs->vs_ops[ZIO_TYPE_WRITE] -
2410
	    oldvs->vs_ops[ZIO_TYPE_WRITE])));
2436
	    oldvs->vs_ops[ZIO_TYPE_WRITE])), cb);
2411
	print_one_stat((uint64_t)(scale * (newvs->vs_bytes[ZIO_TYPE_READ] -
2437
	print_one_stat((uint64_t)(scale * (newvs->vs_bytes[ZIO_TYPE_READ] -
2412
	    oldvs->vs_bytes[ZIO_TYPE_READ])));
2438
	    oldvs->vs_bytes[ZIO_TYPE_READ])), cb);
2413
	print_one_stat((uint64_t)(scale * (newvs->vs_bytes[ZIO_TYPE_WRITE] -
2439
	print_one_stat((uint64_t)(scale * (newvs->vs_bytes[ZIO_TYPE_WRITE] -
2414
	    oldvs->vs_bytes[ZIO_TYPE_WRITE])));
2440
	    oldvs->vs_bytes[ZIO_TYPE_WRITE])), cb);
2415
	(void) printf("\n");
2441
	(void) printf("\n");
Lines 2454-2462 Link Here
2454
	 */
2480
	 */
2455
	if (num_logs(newnv) > 0) {
2481
	if (num_logs(newnv) > 0) {
2456
		(void) printf("%-*s      -      -      -      -      -      "
2482
		if (!cb->cb_scripted) {
2457
		    "-\n", cb->cb_namewidth, "logs");
2483
			(void) printf("%-*s      -      -      -"
2458
2484
			    "      -      -      -\n",
2485
			    cb->cb_namewidth, "logs");
2486
		}
2459
		for (c = 0; c < children; c++) {
2487
		for (c = 0; c < children; c++) {
2460
			uint64_t islog = B_FALSE;
2488
			uint64_t islog = B_FALSE;
2461
			(void) nvlist_lookup_uint64(newchild[c],
2489
			(void) nvlist_lookup_uint64(newchild[c],
Lines 2682-2695 Link Here
2682
	unsigned long interval = 0, count = 0;
2710
	unsigned long interval = 0, count = 0;
2683
	zpool_list_t *list;
2711
	zpool_list_t *list;
2684
	boolean_t verbose = B_FALSE;
2712
	boolean_t verbose = B_FALSE;
2685
	iostat_cbdata_t cb;
2713
	iostat_cbdata_t cb = {0};
2686
	/* check options */
2714
	/* check options */
2687
	while ((c = getopt(argc, argv, "T:v")) != -1) {
2715
	while ((c = getopt(argc, argv, "HT:pv")) != -1) {
2688
		switch (c) {
2716
		switch (c) {
2717
		case 'H':
2718
			cb.cb_scripted = B_TRUE;
2719
			break;
2689
		case 'T':
2720
		case 'T':
2690
			get_timestamp_arg(*optarg);
2721
			get_timestamp_arg(*optarg);
2691
			break;
2722
			break;
2723
		case 'p':
2724
			cb.cb_literal = B_TRUE;
2725
			break;
2692
		case 'v':
2726
		case 'v':
2693
			verbose = B_TRUE;
2727
			verbose = B_TRUE;
2694
			break;
2728
			break;
Lines 2769-2775 Link Here
2769
		if (npools > 1 && !verbose)
2803
		if (npools > 1 && !verbose)
2770
			print_iostat_separator(&cb);
2804
			print_iostat_separator(&cb);
2771
		if (verbose)
2805
		if (verbose && !cb.cb_scripted)
2772
			(void) printf("\n");
2806
			(void) printf("\n");
2773
		/*
2807
		/*

Return to bug 229365