[procps] dynamic spacing in vmstat output?

  • From: Martin Guy <martinwguy@xxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Wed, 21 Feb 2018 12:18:52 +0100

Hi!
   With memory sizes going into 7 digits, vmstat output often goes
skew-whiff on 80-column terminals. Example:

martin@score:~$ vmstat 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0    716 144932 489224 1356956    0    0    40    45  762  351  8  3 88  1
0
 0  0    716 171412 489236 1358704    0    0    17    92 4255 8646 13  3 83  1
0
 1  0    716 146732 489248 1361372    0    0    42    31 4058 8562 12  3 84  1
0

where the "cache" field overflows its 6 chars and pushes all the other
columns right by one.
(you need to see that in fixed-width characters for it to make most sense...)

It would seem better to me to spot when a field has overflowed and
adjust where possible by subtracting a space from the following
column's padding to align the columns again (in this case, outputting
one less space for the "so" column). Obviously, some people will be
matching the fields in scripts; it will continue to work for theose
who match against space-separated fields as they should, not for those
who used column numbers as they shouldn't :) Is that a problem?

The coding isn't trivial because the output is just a printf
formatting string with fixed column widths but I'm an expert Unix
systems programmer and am willing to look at this if people think it
would be worth merging.

Thanks

    M

Other related posts:

  • » [procps] dynamic spacing in vmstat output? - Martin Guy