Project

General

Profile

Feature #3037

vmstat memory output is hard to read on modern systems

Added by Henrik Johansson about 8 years ago.

Status:
New
Priority:
Low
Category:
cmd - userland programs
Start date:
2012-07-28
Due date:
% Done:

40%

Estimated time:
4.00 h
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

The swap and free columns are presented in kilobytes by vmstat today. On modern systems with gigabytes of memory this creates very large numbers that are hard to read. I propose a quick change that does not brake any existing scripts and with minimal code change by implementing a new switch, '-m' that scales these two fields to megabytes instead.

This would make it much more readable for a few years, while keeping enough fine grain to see if a system is increasing memory usage or releasing memory. It will also make the output column match with the header again for most systems and make make more output fit on a single line for those of us who still use 80x24 terminal windows.

Another option would be to include a "-h" option for human readably format like ls, fsstat and other tools. This could however decrease the resolution and require more code/duplication of code ( I don't think there are any suitable scale functions? ) while also making it harder to use the output for scripting.

I've done a simple implementation of this for my own use, I would be glad to clean up the few lines and make this my first contribution.

Example
Today:

$ vmstat 5 2
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr f0 s0 s1 s3   in   sy   cs us sy id
 0 0 0 10026184 6946024 32 127 0 0 0  0 62  1  2  1  3  770  444  591  0  1 99
 0 0 0 9897380 6802728 12 59 0  0  0  0  0  0  0  0  0  847  164  558  0  0 100

With "-m" option:
$ vmstat -m 5 2
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr f0 s0 s1 s3   in   sy   cs us sy id
 0 0 0   9791  6783  32 127  0  0  0  0 62  1  2  0  3  770  443  591  0  1 99
 1 0 0   9665  6643  11  58  0  0  0  0  0  0  0  1 10  816  171  555  0  1 99

Also available in: Atom PDF