Bug 91034 - [patch] minor fix to iostat(8) so that columns line up with 128KB xfers
Summary: [patch] minor fix to iostat(8) so that columns line up with 128KB xfers
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-28 21:20 UTC by rec
Modified: 2017-12-31 22:36 UTC (History)
0 users

See Also:


Attachments
file.diff (1.54 KB, patch)
2005-12-28 21:20 UTC, rec
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rec 2005-12-28 21:20:03 UTC
Iostat's output can be kind of ugly under USF2 with 128KB transfers. Here is an example:

      tty             ad0              ad1             cpu
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
   0   60  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
   0  180  0.00   0  0.00  128.00   8  1.00  48  0  0  0 51
   0   61  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
   0   60  0.00   0  0.00   0.00   0  0.00  49  0  0  0 51

The problem comes from the KB/t column which goes one character too wide.

The patch I'm submitting notices when this value is >= 100 and
drops from 2 decimals to 1 in this case. The result is an output
like this:

      tty             ad0              ad1             cpu
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
   0   60  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
   0  180  0.00   0  0.00  128.0   8  1.00  48  0  0  0 51
   0   61  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
   0   60  0.00   0  0.00   0.00   0  0.00  49  0  0  0 51
        
I find this much easier to read. (A better fix would be to drop
down to 1 decimal digit for all values but I figured that would
be up to you, not me.)

Fix: My fix is trivial but functional. You probably have a better way to do it.
How-To-Repeat: 
Run 'iostat 1' on any machine with periodic (bursty) I/O on a file system.
The results will be as shown above.
Comment 1 Giorgos Keramidas freebsd_committer 2006-01-03 08:28:23 UTC
On 2005-12-28 21:16, Robert Cousins <rec@RCousins.com> wrote:
> Iostat's output can be kind of ugly under USF2 with 128KB
> transfers. Here is an example:
>
>       tty             ad0              ad1             cpu
>  tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
>    0   60  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>    0  180  0.00   0  0.00  128.00   8  1.00  48  0  0  0 51
>    0   61  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>    0   60  0.00   0  0.00   0.00   0  0.00  49  0  0  0 51
>
> The problem comes from the KB/t column which goes one character too wide.
>
> The patch I'm submitting notices when this value is >= 100 and
> drops from 2 decimals to 1 in this case. The result is an output
> like this:
>
>       tty             ad0              ad1             cpu
>  tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
>    0   60  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>    0  180  0.00   0  0.00  128.0   8  1.00  48  0  0  0 51
>    0   61  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>    0   60  0.00   0  0.00   0.00   0  0.00  49  0  0  0 51

The misaligned dots seem a bit ugly.  Is it ok to use %6.2Lf as
the format specifier, widening the KB columns a bit to fit the
new length of the text?
Comment 2 Giorgos Keramidas 2006-01-03 21:46:52 UTC
On 2006-01-03 22:40, Bruce Evans <bde@zeta.org.au> wrote:
>On Tue, 3 Jan 2006, Giorgos Keramidas wrote:
>>On 2005-12-28 21:16, Robert Cousins <rec@RCousins.com> wrote:
>>> Iostat's output can be kind of ugly under USF2 with 128KB
>>> transfers. Here is an example:
>>> ...
>>> The patch I'm submitting notices when this value is >= 100 and
>>> drops from 2 decimals to 1 in this case. The result is an output
>>> like this:
>>>
>>>       tty             ad0              ad1             cpu
>>>  tin tout  KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id
>>>    0   60  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>>>    0  180  0.00   0  0.00  128.0   8  1.00  48  0  0  0 51
>>>    0   61  0.00   0  0.00   0.00   0  0.00  50  0  0  0 50
>>>    0   60  0.00   0  0.00   0.00   0  0.00  49  0  0  0 51
>>
>> The misaligned dots seem a bit ugly.
>
> Indeed.  They are like the -h (hideous or human-unreadable) output
> in many utilities.  Exponential notation and columns that aren't
> lined up are hard for humans to read.
>
> >Is it ok to use %6.2Lf as
> >the format specifier, widening the KB columns a bit to fit the
> >new length of the text?
>
> No.  There is space in the above, but most systems have more than 2 drives
> (most of mine have 6, with 4 physical drives and extras from atapicam
> duplicating acd0 and cam giving a virtual drive pass0).  Info about 3
> drives just fits in 80 columns with %5.2Lf format.  It results in 77
> coumns being used.  %6.2Lf format would result in 80 columns being used
> and thus ugly line wrap on some terminals (or the number of drives being
> limited to 2).

So, there's no way to keep the pretty format of current iostat output
*and* account for larger transfer speeds? :-(

Looking at an awk-formatted version of the iostat output it seems that
even with 3 disks we *do* hae 3 columns to spare until 79 columns are
reached:

$ iostat ad0 da0 pass0 | awk '{printf "%-78s|\n",$0}'
      tty             ad0              da0            pass0             cpu   |
 tin tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id   |
  63  514  7.10  13  0.09   0.01   0  0.00   0.00   0  0.00   1  0  2  0 96   |
$

Is this enough for adding an extra column to every KB/t column and
still keeping everything under 80 columns?
Comment 3 fullermd 2006-01-04 00:42:06 UTC
On Tue, Jan 03, 2006 at 09:50:09PM +0000 I heard the voice of
Giorgos Keramidas, and lo! it spake thus:
>  
>  So, there's no way to keep the pretty format of current iostat
>  output *and* account for larger transfer speeds? :-(

Drop to one digit after the decimal point?  100-byte granularity
sounds reasonable for such an overview tool.


-- 
Matthew Fuller     (MF4839)   |  fullermd@over-yonder.net
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.
Comment 4 Bruce Evans 2006-01-04 02:09:02 UTC
On Tue, 3 Jan 2006, Giorgos Keramidas wrote:

> On 2006-01-03 22:40, Bruce Evans <bde@zeta.org.au> wrote:
>> On Tue, 3 Jan 2006, Giorgos Keramidas wrote:
>>> On 2005-12-28 21:16, Robert Cousins <rec@RCousins.com> wrote:
>>>> Iostat's output can be kind of ugly under USF2 with 128KB
>>>> transfers. Here is an example:
>>>> ...
>>>> The patch I'm submitting notices when this value is >= 100 and
>>>> drops from 2 decimals to 1 in this case. The result is an output
>>>> like this:
>>> ...
>>> The misaligned dots seem a bit ugly.
>> ...
>>> Is it ok to use %6.2Lf as
>>> the format specifier, widening the KB columns a bit to fit the
>>> new length of the text?
>>
>> No.  There is space in the above, but most systems have more than 2 drives
>> ...
>
> So, there's no way to keep the pretty format of current iostat output
> *and* account for larger transfer speeds? :-(

Maybe always drop %5.1Lf format for disk MB/s.  If the value is < 0.10
MB/s then it is so low that you don't really care if it is 0.01 or 0.09.
However, floppies have a top speed of about 0.04, and speeds below
0.10 are all too common for faster disks doing too many seeks.

> Looking at an awk-formatted version of the iostat output it seems that
> even with 3 disks we *do* hae 3 columns to spare until 79 columns are
> reached:
>
> $ iostat ad0 da0 pass0 | awk '{printf "%-78s|\n",$0}'
>      tty             ad0              da0            pass0             cpu   |
> tin tout  KB/t tps  MB/s   KB/t tps  MB/s   KB/t tps  MB/s  us ni sy in id   |
>  63  514  7.10  13  0.09   0.01   0  0.00   0.00   0  0.00   1  0  2  0 96   |
> $

>
> Is this enough for adding an extra column to every KB/t column and
> still keeping everything under 80 columns?

No, since there are actually only 2 columns to spare.  "id" sometimes
takes an extra column since it is sometimes 100.  I hacked its format
in rev.1.25 of iostat.c from %3.0f to " %2.0f".  The space keeps it
from running into "in", and reducing the field width keeps the line
length the same except when cpu is 100 when it doesn't fit in %2.0f.
As mentioned in the log message for this, larger fixes are needed.
I think they should be something like
"iostat -w N | awk '{printf "%*.*s %*.*s ...\n", $1, $2, ...}'" where the
awk script calculates the column widths dynamically and is actually
a library function.  This should also work for ps and df.  It's easier
for them since all the input can be read before doing any output.
Except I'd like ps to have a "repeat" arg like iostat, for watching
a few selected processes better than top(1) or repeatedly rerunning
ps(1) can do.

Bruce
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:16 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped