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 [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message

Reply via email to