TrumanWong

vmstat

Show virtual memory status

Supplementary instructions

The vmstat command means to display virtual memory status ("Viryual Memor Statics"), but it can report on the overall operating status of the system such as processes, memory, I/O, etc.

grammar

vmstat(options)(parameters)

Options

-a: Display the inner page of the event;
-f: Displays the total number of processes created after startup;
-m: Display slab information;
-n: The header information is only displayed once;
-s: Display event counters and memory status in table format;
-d: Report disk status;
-p: Display the specified hard disk partition status;
-S: Unit of output information.

Parameters

  • Event interval: the time interval for status information refresh;
  • Count: Display the number of times reported.

Example

vmstat 3
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu ------
  r b swpd free buff cache si so bi bo in cs us sy id wa st
  0 0 320 42188 167332 1534368 0 0 4 7 1 0 0 0 99 0 0
  0 0 320 42188 167332 1534392 0 0 0 0 1002 39 0 0 100 0 0
  0 0 320 42188 167336 1534392 0 0 0 19 1002 44 0 0 100 0 0
  0 0 320 42188 167336 1534392 0 0 0 0 1002 41 0 0 100 0 0
  0 0 320 42188 167336 1534392 0 0 0 0 1002 41 0 0 100 0 0

Field description:

Procs (process)

  • r: The number of processes in the run queue. This value can also be used to determine whether the CPU needs to be increased. (long term greater than 1)
  • b: Number of processes waiting for IO.

Memory

  • swpd: Use virtual memory size. If the value of swpd is not 0, but the values of SI and SO are 0 for a long time, this situation will not affect system performance.
  • free: Free physical memory size.
  • buff: The memory size used as buffer.
  • Cache: The memory size used as cache. If the cache value is large, it means that there are many files in the cache. If frequently accessed files can be cached, the disk read IO bi will be very small.

Swap

  • si: The size written from the swap area to the memory per second, which is transferred into the memory from the disk.
  • so: The memory size written to the swap area per second, transferred from memory to disk.

Note: When the memory is sufficient, these two values ​​are both 0. If these two values ​​are greater than 0 for a long time, system performance will be affected, and disk IO and CPU resources will be consumed. Some friends think that the memory is not enough when they see that the free memory (free) is very small or close to 0. You can't just look at this, but also combine si and so. If there is very little free, there are also very few si and so. (Most of the time it is 0), then don’t worry, system performance will not be affected at this time.

IO (current Linux version block size is 1kb)

  • bi: Number of blocks read per second
  • bo: Number of blocks written per second

Note: When reading and writing random disks, the larger these two values ​​are (such as exceeding 1024k), the larger the value you can see that the CPU is waiting for IO.

system

  • in: Number of interrupts per second, including clock interrupts.
  • cs: Number of context switches per second.

Note: The larger the above two values are, the greater the CPU time consumed by the kernel will be.

CPU (expressed as a percentage)

  • us: Percentage of user process execution time (user time)

When the value of us is relatively high, it means that the user process consumes a lot of CPU time, but if the usage exceeds 50% for a long time, then we should consider optimizing the program algorithm or accelerating it.

  • sy: Percentage of kernel system process execution time (system time)

When the value of sy is high, it means that the system kernel consumes a lot of CPU resources. This is not a benign performance and we should check the reason.

  • wa: IO waiting time percentage

When the value of wa is high, it means that the IO wait is serious. This may be caused by a large number of random accesses on the disk, or there may be a bottleneck (block operation) on the disk.

  • id: idle time percentage