[Bug 201685] top(1) with -m io produces garbage output for first update

Bruce Evans brde at optusnet.com.au
Mon Jun 25 05:07:05 UTC 2018


On Sun, 24 Jun 2018 a bug that does't want replies at freebsd.org wrote:

> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201685
>
> --- Comment #4 from cstdenis at ctgameinfo.com ---
> I encountered this error because I was trying to log periodic snapshots of top
> output as part of tracking down some system issues.
>
> i.e. (/root/datestamp.sh; /usr/bin/top -j -t -mio -ototal) >>
> /var/log/top_io.log
>
> Having it do a "dummy" run before outputting would be a great fix and make that
> kind of logging possible. As it is, the above command is useless.

The only bug here is misformatting of large values.  top -m io just starts by
displaying the counts since boot time.  These can be very large after a long
uptime.  top uses fixed field widths, and has no space available for wider
dynamic widths anyway, so it misaligns large values.

The fix is not to display values in dehumanized (scientific) format like
systat does by default and some utilities do when directed to do so by a
-[hH] (dehumanize) flag.

I use this feature to log benchmarks.  top -SH -m io -o write 1000 gives
non-interactive output.  This is logged at the beginning and end of the
benchmark.  Only the delta-counts are of interest.  These are hard to
manage and I don't have any good scripts to manage them, but sometimes
look at a couple of lines and compare the values.  Any dehumanized output
would break the resolutions.  Counts of 1000000 and 1000001 would be
indistinguishable if displayed as 1M.

Bruce


More information about the freebsd-bugs mailing list