Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 May 2007 01:12:06 -0500 (CDT)
From:      Dan Nelson <dnelson@allantgroup.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/112559: [PATCH] make iostat -Ix work
Message-ID:  <200705100612.l4A6C6rA016282@dan.emsphone.com>
Resent-Message-ID: <200705100630.l4A6U5Of044272@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         112559
>Category:       bin
>Synopsis:       [PATCH] make iostat -Ix work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 10 06:30:04 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Dan Nelson
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 6.2-STABLE FreeBSD 6.2-STABLE #434: Wed Jan 24 11:11:58 CST 2007 zsh@dan.emsphone.com:/usr/src-6/sys/i386/compile/DANSMP i386


	
>Description:

The code to print the extended device stats doesn't take the -I flag
into account.

	
>How-To-Repeat:
	
>Fix:

With the following patch, "iostat -xI" will print per-interval I/O
statistics instead of per-second ones (which means the first line shows
totals since boot).  Applies cleanly to HEAD and RELENG-6.

Index: iostat.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/iostat/iostat.c,v
retrieving revision 1.32
diff -u -p -r1.32 iostat.c
--- iostat.c	6 Feb 2007 20:29:40 -0000	1.32
+++ iostat.c	10 May 2007 06:02:03 -0000
@@ -656,6 +656,8 @@ devstats(int perf_select, long double et
 	long double transfers_per_second, transfers_per_second_read, transfers_per_second_write;
 	long double kb_per_transfer, mb_per_second, mb_per_second_read, mb_per_second_write;
 	u_int64_t total_bytes, total_transfers, total_blocks;
+	u_int64_t total_bytes_read, total_transfers_read;
+	u_int64_t total_bytes_write, total_transfers_write;
 	long double busy_pct;
 	u_int64_t queue_len;
 	long double total_mb;
@@ -670,7 +672,10 @@ devstats(int perf_select, long double et
 		if (Cflag > 0)
 			printf("           cpu ");
 		printf("\n");
-		printf("device     r/s   w/s    kr/s    kw/s wait svc_t  %%b  ");
+		if (Iflag == 0)
+			printf("device     r/s   w/s    kr/s    kw/s wait svc_t  %%b  ");
+		else
+			printf("device     r/i   w/i    kr/i    kw/i wait svc_t  %%b  ");
 		if (Tflag > 0)
 			printf("tin tout ");
 		if (Cflag > 0)
@@ -690,7 +695,11 @@ devstats(int perf_select, long double et
 		if (devstat_compute_statistics(&cur.dinfo->devices[di],
 		    havelast ? &last.dinfo->devices[di] : NULL, etime,
 		    DSM_TOTAL_BYTES, &total_bytes,
+		    DSM_TOTAL_BYTES_READ, &total_bytes_read,
+		    DSM_TOTAL_BYTES_WRITE, &total_bytes_write,
 		    DSM_TOTAL_TRANSFERS, &total_transfers,
+		    DSM_TOTAL_TRANSFERS_READ, &total_transfers_read,
+		    DSM_TOTAL_TRANSFERS_WRITE, &total_transfers_write,
 		    DSM_TOTAL_BLOCKS, &total_blocks,
 		    DSM_KB_PER_TRANSFER, &kb_per_transfer,
 		    DSM_TRANSFERS_PER_SECOND, &transfers_per_second,
@@ -731,12 +740,21 @@ devstats(int perf_select, long double et
 			    mb_per_second_read > ((long double).0005)/1024 ||
 			    mb_per_second_write > ((long double).0005)/1024 ||
 			    busy_pct > 0.5) {
-				printf("%-8.8s %5.1Lf %5.1Lf %7.1Lf %7.1Lf %4qu %5.1Lf %3.0Lf ",
-				    devname, transfers_per_second_read,
-				    transfers_per_second_write,
-				    mb_per_second_read * 1024,
-				    mb_per_second_write * 1024, queue_len,
-				    ms_per_transaction, busy_pct);
+				if (Iflag == 0)
+					printf("%-8.8s %5.1Lf %5.1Lf %7.1Lf %7.1Lf %4qu %5.1Lf %3.0Lf ",
+					    devname, transfers_per_second_read,
+					    transfers_per_second_write,
+					    mb_per_second_read * 1024,
+					    mb_per_second_write * 1024, queue_len,
+					    ms_per_transaction, busy_pct);
+				else
+					printf("%-8.8s %5.1Lf %5.1Lf %7.1Lf %7.1Lf %4qu %5.1Lf %3.0Lf ",
+					    devname, (long double)total_transfers_read,
+					    (long double)total_transfers_write,
+					    (long double)total_bytes_read / 1024,
+					    (long double)total_bytes_write / 1024, queue_len,
+					    ms_per_transaction, busy_pct);
+				
 				if (firstline) {
 					/*
 					 * If this is the first device

	


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705100612.l4A6C6rA016282>