How to monitor system memory and swap utilization on Ubuntu Server 20.04
In the last post, we used commands top and vmstat to monitor CPU utilization. These commands also provided details of memory usage.
Step 1 : Run the top command and check for the Mem and Swap rows
Step 2 : You can query memory statistics for a specific PID or program by using the pidstat command.
pidstat -C mysql -r
Step 3 : Next, we will go through the vmstat command.
vmstat vmstat -s
Step 4 : Another handy command is free
Step 5 : Finally, command sar can give you periodic reports of memory utilization.
The following command will query the current memory (-r) and swap (-S) utilization
sar -rS 1 5