Bug 221290 - vmstat output have columns without space
Summary: vmstat output have columns without space
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Oleksandr Tymoshenko
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-08-06 19:37 UTC by Josuah Demangeon
Modified: 2024-01-05 04:45 UTC (History)
1 user (show)

See Also:


Attachments
I attached a patch applied to the git repo, and I could not test it with this version, but applying the same edit on 11.0-RELEASE worked fine. (437 bytes, patch)
2017-08-06 19:37 UTC, Josuah Demangeon
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josuah Demangeon 2017-08-06 19:37:08 UTC
Created attachment 185098 [details]
I attached a patch applied to the git repo, and I could not test it with this version, but applying the same edit on 11.0-RELEASE worked fine.

vmstat displays humanized numbers while stdout is a TTY.  But while piping out through, say, tee(1), the numbers under fre and flt are displayed without any " " when flt's numbers are too big.


To reproduce:


    ─── stress -m 1 -t 3 & vmstat 1 3 | tee
    [1] 9628
    stress: info: [9628] dispatching hogs: 0 cpu, 0 io, 1 vm, 0 hdd
    procs     memory        page                    disks     faults         cpu
    r b w     avm     fre  flt  re  pi  po    fr   sr ad0 pa0   in    sy    cs us sy id
    1 0 0 4691676 12188436 1408   0 173   8  1490  171   0   0  192  6998  1832  8  1 91
    1 0 0 4935316 12036000496115   0   0  12 461929  229   0   0    3   372   156  4 23 73
    1 0 0 4935316 12062292518046   0   0   0 527749  287   0   0    2   627   170  3 24 73
    stress: info: [9628] successful run completed in 3s
    ─── 


By adding a xo_emit(" ") on dovmstat() { ... } seems to fix the problem (see attached patch).
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-08-08 12:18:21 UTC
A commit references this bug:

Author: manu
Date: Tue Aug  8 12:18:11 UTC 2017
New revision: 322252
URL: https://svnweb.freebsd.org/changeset/base/322252

Log:
  vmstat: Always emit a space after the free-memory column

  When displaying in non-human form, if the free-memory number
  is large (more than 7 digits), there is no space between it and
  the page fault column.

  PR:		221290
  Submitted by:	Josuah Demangeon <mail@josuah.net> (Original version)

Changes:
  head/usr.bin/vmstat/vmstat.c
Comment 2 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-21 21:42:10 UTC
I'll take care of MFC
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2024-01-05 04:45:54 UTC
^Triage: committed back in 2017.