I. Preface
Obviously from the name we can know that vmstat is a tool to check the usage of virtual memory, but how to find the bottleneck in the system through vmstat? Before answering this question, let us review the virtual memory related content in Linux.
Second, the virtual memory operating principle
Each process running in the system needs to use memory, but not every process needs to use the system allocated memory space all the time. When the system requires more memory than the actual physical memory, the kernel will release some or all of the physical memory occupied by some processes, and store this part of the data on the disk until the next call of the process, and the memory will be released. Provided to processes that need it.
In Linux memory management, the above memory scheduling is mainly done through "Paging" and "Exchange Swapping". The paging algorithm replaces the recently infrequently used pages in memory to disk and keeps the active pages in memory for use by the process. Switching technology is to swap entire processes, not partial pages, to disk.
The process of writing to the disk is called Page-Out. The process of paging back from disk to memory is called Page-In. When the kernel needs a page, it finds This page break is not in physical memory (because it has been Page-Out), and a Page Fault occurs.
When the system kernel finds that there is less running memory, it will release some of the physical memory through Page-Out. The management of Page-Out does not happen often, but if Page-out occurs frequently, the system performance will drop dramatically until the time the kernel manages the paging exceeds the time of running the program. At this time, the system has been running very slowly or entering a pause state, which is also called thrashing.
Third, use 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]]
vmstat [-f]
vmstat [- V]
-a: Display active and inactive memory
-f: Display the number of forks since system startup.
-m: Display slabinfo
-n: Display each field name only once at the beginning.
-s: Displays memory-related statistics and the number of various system activities.
delay: The refresh interval. If not specified, only one result is displayed.
count: The number of refreshes. If you do not specify the number of refreshes, but specify a refresh interval, then the number of refreshes is infinite.
-d: Display disk related statistics.
-p: Display the specified disk partition statistics
-S: Display using the specified unit. The parameters are k, K, m, and M, representing 1000, 1024, 1000000, and 1048576 bytes, respectively. The default unit is K (1024 bytes)
-V: Display vmstat version information.
2. Instructions for use
Example 1: Output a result every 2 seconds
Field Description:
Procs(process):
r: Number of processes in the run queue
b: Number of processes waiting for IO
Memory:
swpd: Use virtual memory size
Free: available memory size
buff: memory size used as buffer
cache: memory size used as cache
Swap:
si: per Seconds written from swap area to memory size
so: memory size written to swap area per second
IO: (current Linux version block size 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: Number of context switches per second.
CPU (in percent):
us: user process execution time (user time)
sy: system process execution time (system time)
id: Idle time (including IO wait time)
wa: Waiting for IO time
Example 2: Display active and inactive memory
Use the -a option to display active and In the case of inactive memory, the displayed content is the same as in Example 1 except that inact and active are added.
Field Description:
Memory:
inact: Inactive memory size (displayed when the -a option is used)
active: active Memory size (displayed when the -a option is used)
What should I do if the Ubuntu system Grub fails? Many computer users think of reloading: Grub, howe
Compiled linux kernel has been 3 times, each compilation needs to go online to find the compilation
The following folder on the desktop is shared as a shared folder to the Linux system in the virtual
one, top command 1. Function The top command is used to display the program process in execution,
Linux task planning tool crontab
Build your own Linux system reflection (2)
Ubuntu under the bower report EACCES: permissiondenied solution
Setting up the CentOS firewall open port
Introduction to vim installation and basic configuration under Ubuntu
Method for obtaining path file name in Linux system
Remove components hidden deep in XP system
Using win7 system drawing function to quickly cut pictures
What if Win10 System Windows Media Player cannot load subtitles?
How does Win8 turn Windows features on or off
Windows 7 can not be closed service command
Windows10 start menu jump list function how to set to start open
Server Maintenance: Knowledge of the Event Viewer
Win10 Preview 10162 Push Update: Improve Battery Life
Microsoft confirmed the acquisition of home entertainment technology company R2
For Win10 (Mobile), Microsoft shows high-profile love to Apple and iOS developers