[Toybox] New toy: vmstat
Elie De Brauwer
eliedebrauwer at gmail.com
Mon Apr 9 04:39:14 PDT 2012
Hello all,
In attachment you can find a no-nonsense vmstat implementation. Meaning
most of the special things (which I personally never bothered to use)
are dropped. (vmstat -d however is still under consideration, please
shout if you're waiting for a vmstat -d or any other options).
The information is gathered from procfs and assumes linux >2.6.x. One
last comment is vmstat's dreaded first line where it tries to average
the counters (where possible) is imho just broken.
Observe the snippet below:
edb at lapedb:~/today$ cat /proc/stat | grep ctxt ; cat /proc/uptime ; vmstat
ctxt 3021508
2317.09 17079.93
procs -----------memory---------- ---swap-- -----io---- -system--
----cpu----
r b swpd free buff cache si so bi bo in cs us sy
id wa
0 0 0 5773748 71032 1915324 0 0 100 83 126 163 6
1 92 1
Here I would expect the summary line to display the number of context
switchs per second which is 3021508/2317 = 1304. However vmstat states
this as 163. Now let's do some magic 163*8 = 1304. (Where 8 is the
number of cpu's my laptop shows). Hence the result they give is number
per second per core. While consecutive runs show the total value per
second. So I ended up implementing the first line as something which is
(in imho) what is was supposed to be. I will throw this odd behavior of
vmstat back upstream.
my 2 cents, feedback welcome.
gr
E.
--
Elie De Brauwer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vmstat.patch
Type: text/x-patch
Size: 7677 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20120409/2c86d730/attachment.bin>
More information about the Toybox
mailing list