Troubleshoot Linux Server Performance Using vmstat Command
We can do troubleshooting with vmstat command for Linux monitoring performance in Linux. Vmstat is used to monitor the server performance using the command line and it shows you the information including CPU, Block I/O, Swap, Process, memory, and paging.
If you don’t find vmstat command, you can install using yum -y vmstat
The output will be broken into 6 parts: so
r: The number of process waiting for run time
b: The number of process in uninterruptible sleep
swpd: Amount of Virtual memory used.
free: idle memory
buff: memory used as buffers.
cache: memory used as a cache.
inact: inactive memory
active: active memory
si: The amount of memory swapped in from disk.
so: The amount of memory swapped to disk.
bi: Blocks received from a block device
bo: Blocks sent to a block device
in: interrupts per second, including the clock.
cs: The number of context switches per second.
CPU: These are percentages of total CPU time.
us: Amount of time that the processor spends on user tasks.
sy: Amount of time that processor spends on kernel related tasks
id: Amount of time spends idle.
wa: Amount of time that processor waiting for IO.
st: Amount of time stolen from a virtual machine.
Example 1: It displays active and inactive memory of the system running on the server. so
Example 2: you want to check the slab information. It means a set of one or more contiguous pages of memory set aside by the slab allocator for an individual cache. It’s a memory management mechanism. so
If you don’t find any information, it depends on your kernel. so
vmstat -m | more
Example 3: It executes every 2 seconds and stops automatically after 5 intervals. so
vmstat 2 5
Example 4: Check disk statistics using vmstat -d so
Example 5: you can also display the timestamp using vmstat -t delay count so
vmstat -t 2 4
Example 6: Display the size in Megabytes.
vmstat -S M 2 4
Example 7: you can display header only once after delay and count.
vmstat -n 2 4
Example 8: Displays the number of forks since last boot.
Example 9: it displays the width of the output using the ‘-w’ option.
vmstat -w 2 4
Example 10: we can display the I/O statistics of a particular disk using vmstat -p /dev/xvda1
You’re done Troubleshoot Linux Server Performance monitoring command in linux vmstat