From owner-freebsd-stable Mon Aug 27 22:28:22 2001 Delivered-To: freebsd-stable@freebsd.org Received: from mozone.net (mail.mozone.net [206.165.200.53]) by hub.freebsd.org (Postfix) with ESMTP id B06D437B407 for ; Mon, 27 Aug 2001 22:28:16 -0700 (PDT) (envelope-from mki@mozone.net) Received: (from mki@localhost) by mozone.net (8.11.2/8.11.2) id f7S5S6j10689 for freebsd-stable@freebsd.org; Mon, 27 Aug 2001 22:28:06 -0700 Date: Mon, 27 Aug 2001 22:28:06 -0700 From: mki To: freebsd-stable@freebsd.org Subject: thoughts on %busy in iostat Message-ID: <20010827222806.U1286@cyclonus.mozone.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG It would be cool if iostat would show %busy times, I managed to get this into my local copy (see attached), by taking some of the stuff off of systat. Thoughts? -mohan --- /usr/src/usr.sbin/iostat/iostat.c Thu Aug 16 18:33:52 2001 +++ iostat.c Mon Aug 20 10:21:41 2001 @@ -563,14 +563,14 @@ && (dev_select[i].selected <= maxshowdevs)) { if (oflag > 0) { if (Iflag == 0) - (void)printf(" sps tps msps "); + (void)printf(" sps tps msps %%b "); else - (void)printf(" blk xfr msps "); + (void)printf(" blk xfr msps %%b "); } else { if (Iflag == 0) - printf(" KB/t tps MB/s "); + printf(" KB/t tps MB/s %%b "); else - printf(" KB/t xfrs MB "); + printf(" KB/t xfrs MB %%b "); } printed++; } @@ -592,6 +592,7 @@ long double busy_seconds; long double total_mb; long double blocks_per_second, ms_per_transaction; + long double device_busy; /* * Calculate elapsed time up front, since it's the same for all @@ -608,6 +609,9 @@ di = dev_select[dn].position; + device_busy = compute_etime(cur.dinfo->devices[di].busy_time, + last.dinfo->devices[di].busy_time); + if (compute_stats(&cur.dinfo->devices[di], &last.dinfo->devices[di], busy_seconds, &total_bytes, &total_transfers, @@ -629,35 +633,50 @@ block_size : 512) / 1024; } + + if ((device_busy == 0) && (transfers_per_second > 5)) + /* the device has been 100% busy, fake it because + * as long as the device is 100% busy the busy_time + * field in the devstat struct is not updated */ + device_busy = busy_seconds; + if (device_busy > busy_seconds) + /* this normally happens after one or more periods + * where the device has been 100% busy, correct it */ + device_busy = busy_seconds; + if (oflag > 0) { int msdig = (ms_per_transaction < 100.0) ? 1 : 0; if (Iflag == 0) - printf("%4.0Lf%4.0Lf%5.*Lf ", + printf("%4.0Lf%4.0Lf%5.*Lf%4.0Lf%% ", blocks_per_second, transfers_per_second, msdig, - ms_per_transaction); + ms_per_transaction, + device_busy*100/busy_seconds); else - printf("%4.1qu%4.1qu%5.*Lf ", + printf("%4.1qu%4.1qu%5.*Lf%4.0Lf%% ", total_blocks, total_transfers, msdig, - ms_per_transaction); + ms_per_transaction, + device_busy*100/busy_seconds); } else { if (Iflag == 0) - printf(" %5.2Lf %3.0Lf %5.2Lf ", + printf(" %5.2Lf %3.0Lf %5.2Lf%4.0Lf ", kb_per_transfer, transfers_per_second, - mb_per_second); + mb_per_second, + device_busy*100/busy_seconds); else { total_mb = total_bytes; total_mb /= 1024 * 1024; - printf(" %5.2Lf %3.1qu %5.2Lf ", + printf(" %5.2Lf %3.1qu %5.2Lf%4.0Lf ", kb_per_transfer, total_transfers, - total_mb); + total_mb, + device_busy*100/busy_seconds); } } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message