Vmstat is a tool that looks at virtual memory usage and uses the VMSTAT command to get information about processes, memory, memory paging, blocking IO, traps, and CPU activity. This paper introduces the operating principle of virtual memory, and then introduces the usage and usage examples of vmstat.
First, virtual memory operating principle
Each process running in the system needs to use memory, but not every process needs to use the system's allocated memory space every moment. When the system is running more memory than the actual physical memory, the kernel frees some or all of the physical memory that some processes occupy but unused, stores that data on disk until the next call to the process, and provides the freed memory for use by the required process. Www.ahlinux.com
In the Linux memory management, mainly through "paging paging" and "exchange swapping" to complete the above memory scheduling. Paging algorithm is to swap the most recently used pages in memory to disk, leaving the active page in memory for the process to use. The switching technique is to swap the entire process, not some pages, to disk.
The process of paging (page) writing to disk is called Page-out, and Paging (page) back to memory from disk is called page-in. Paging error (page Fault) occurs when the kernel needs a paging, but finds that the paging is not in physical memory (because it has been page-out).
When the system kernel discovers that it is running out of memory, it releases a portion of the physical memory through Page-out. Operating page-out is not a frequent occurrence, but if the page-out occurs frequently, the system's performance will drop sharply until the kernel manages paging more than the time the program is running. At this point the system is already running very slowly or going into a paused state, which is also known as thrashing (bump).
Second, the use of Vmstat
1. Usage
Vmstat [-A] [-n] [-s unit] [delay [count]]
Vmstat [-S] [-n] [-s unit]
Vmstat [-M] [-n] [delay [count]]
Vmstat [-d] [-n] [delay [count]]
Vmstat [-P disk partition] [-n] [delay [count]]
Www.ahlinux.com
Vmstat [-F]
Vmstat [-v]
-A: Show active and inactive memory
-F: Displays the number of fork from the system since it was started.
-M: Display Slabinfo
-N: Displays the field names only once at the beginning.
-S: Displays memory-related statistics and the number of system activities.
Delay: Refresh time interval. If not specified, only one result is displayed.
Count: Number of refreshes. If you do not specify the number of refreshes, but the refresh interval is specified, the number of refreshes is infinite.
-D: Displays disk-related statistics.
-P: Display specified disk partition statistics
-S: Displayed using the specified units. The parameters are K, K, M, M, respectively, representing 1000, 1024, 1000000, 1048576 bytes (byte). The default unit is K (1024x768 bytes)
-V: Displays Vmstat version information.
2. Instructions for use
Example 1: Output a result every 2 seconds
Field Description:
Procs (Process):
Www.ahlinux.com
R: Number of processes in the running queue
B: Number of processes waiting for IO
Memory (RAM):
SWPD: Using virtual memory size
Free: Available memory size
Buff: The amount of memory used as a buffer
Cache: The amount of memory used as a buffer
Swap:
Si: Write to memory size per second from swap area
So: The amount of memory written to the swap area per second
IO: (now the size of the Linux version block is 1024bytes)
BI: Number of blocks read per second
Bo: Number of blocks written per second
System:
In: Number of interrupts per second, including clock interrupts.
CS: The number of context switches per second.
CPU (expressed as a percentage):
US: User Process Execution Time
SY: System Process Execution time
ID: Idle time (including IO wait time)
WA: Waiting for IO time
Www.ahlinux.com
Example 2: Show active and inactive memory
When you use the-a option to display both active and inactive memory, the displayed content is the same as example 1 except for adding inact and active.
Field Description:
Memory (RAM):
Inact: Inactive memory Size (displayed when the-a option is used)
Active: Active memory size (displayed when the-a option is used)
Author cooldream666
- This article is from: Linux Tutorial Network
Linux Monitoring Tools Vmstat use