From ea99502577ee7cac26c4e99add0611b147f7d2ee Mon Sep 17 00:00:00 2001 From: in2 Date: Sun, 30 Mar 2003 07:40:20 +0000 Subject: =?UTF-8?q?=EF=BF=BD=EF=BF=BD=EF=BF=BDT=EF=BF=BD=EF=BF=BD=EF=BF=BD?= =?UTF-8?q?p=EF=BF=BD=EF=BF=BD=EF=BF=BD@=EF=BF=BD=EF=BF=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@750 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/diskstat.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'util/diskstat.c') diff --git a/util/diskstat.c b/util/diskstat.c index f4146026..829613f9 100644 --- a/util/diskstat.c +++ b/util/diskstat.c @@ -543,6 +543,18 @@ phdr(int signo) { register int i; int printed; + static char firsttime = 1; + if( firsttime ){ + firsttime = 0; + for( i = 0 ; i < num_devices ; ++i ){ + int di = dev_select[i].position; + if( strcmp(cur.dinfo->devices[di].device_name, "ad") != 0 && + strcmp(cur.dinfo->devices[di].device_name, "da") != 0 ){ + maxshowdevs = i; + break; + } + } + } if ((dflag == 0) || (Tflag > 0)) (void)printf(" tty"); @@ -556,7 +568,7 @@ phdr(int signo) cur.dinfo->devices[di].device_name, cur.dinfo->devices[di].unit_number); else - printf("%4s%d ", + printf("%6s%d", cur.dinfo->devices[di].device_name, cur.dinfo->devices[di].unit_number); printed++; @@ -580,7 +592,7 @@ phdr(int signo) (void)printf(" blk xfr msps "); } else { if(Bflag) - printf(" busy "); + printf(" busy"); else if (Iflag == 0) printf(" KB/t tps MB/s "); else @@ -602,10 +614,13 @@ static void printresult(int p) { int dn; printf("\n"); - phdr(0); - for (dn = 0; dn < maxshowdevs; dn++) - printf(" %3d%% ", (busydata[dn] / counttimes)); - printf("\n"); + if( counttimes > 0 ){ + printf("--- diskstat statistics (%d samples)---\n", counttimes); + phdr(0); + for (dn = 0; dn < maxshowdevs; dn++) + printf(" %5.1f%%", ((float)busydata[dn] / 10 / counttimes)); + printf("\n"); + } exit(0); } @@ -628,7 +643,7 @@ devstats(int perf_select) busy_seconds = compute_etime(cur.busy_time, last.busy_time); for (dn = 0; dn < num_devices; dn++) { - int di; + int di, thisbusy; if (((perf_select == 0) && (dev_select[dn].selected == 0)) || (dev_select[dn].selected > maxshowdevs)) @@ -639,7 +654,9 @@ devstats(int perf_select) device_busy = compute_etime(cur.dinfo->devices[di].busy_time, last.dinfo->devices[di].busy_time); - busydata[dn] += (int)(device_busy*100/busy_seconds); + thisbusy = device_busy*1000/busy_seconds; + busydata[dn] += thisbusy; + if (compute_stats(&cur.dinfo->devices[di], &last.dinfo->devices[di], busy_seconds, &total_bytes, &total_transfers, @@ -678,7 +695,7 @@ devstats(int perf_select) ms_per_transaction); } else { if (Bflag) - printf(" %3d%% ", (int)(device_busy*100/busy_seconds)); + printf(" %5.1f%%", (float)thisbusy / 10); else if (Iflag == 0){ printf(" %5.2Lf %3.0Lf %5.2Lf ", kb_per_transfer, -- cgit v1.2.3