1

Running vmstat will give you the average virtual memory usage since last reboot. The si and so values give the average virtual memory I/O. For example:

root@mymachine# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0    304 300236 244940 967828    0    0     0     1    2    1  0  0 100  0  0

As Ijaz Khan answered, I can how many times I want vmstat to run, as well as the increments in between. This is useful in some cases (+1), but I do not want to have to leave vmstat running.

I want to be able collect the data, then reset the counters so I can leave it for a while, then come back to get an average of from when I reset the counters to when I next check -- instead of since the last boot. Is that possible?

2

The memory information isn't averaged; vmstat shows the instantaneous memory information as provided in /proc/meminfo. So you can use the memory information from vmstat without worrying about changes since the last boot.

The values that are accumulated since boot concern the CPU usage, interrupts and context switches, and swap in/out and pages in/out; these are never reset. You can read the raw values from /proc/stat and /proc/vmstat if you want to be able to calculate your own deltas. For example, si is pswpin from /proc/vmstat, bi is pgpgin from /proc/vmstat.

| improve this answer | |
  • vmstat is using old data as a part of the average, if the server has not rebooted in a long time. I can't get a more recent I/O average just by calculating the difference... Unless I'm not understanding you. Could you please clarify? – Questionmark Dec 19 '16 at 15:59
  • The memory information isn't averaged, so you can always calculate a difference on that. – Stephen Kitt Dec 19 '16 at 16:13
  • Hang on -- si, so, bi and bo aren't averages??? I am mainly interested in the average si and so... – Questionmark Dec 19 '16 at 16:14
  • 1
    Only the memory information isn't averaged, the rest is. So you'd need to look at the raw values used by vmstat. – Stephen Kitt Dec 19 '16 at 16:23
1

Consider the following output:

$ vmstat 
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0   3532 148760  50700 1397880    0    0     1     2    6    6  3  1 97  0

This data provides an average view of virtual memory and system usage since the last reboot. Often, the following form of the command is used:

vmstat [interval] [count]

In this example, the first line of data will provide the average since the last boot time ( which you can discard).

Subsequent reports, until [count] is reached ( will stop the vmstat), report data on the current state of the system every [interval] seconds.

| improve this answer | |
  • See my initial post: "I know that I can specify how many times I want vmstat to run, as well as the increments in between. I do not want to have to leave vmstat running." -- I do know about that, but I didn't want to have to leave vmstat running for an hour... – Questionmark Dec 19 '16 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.