How to monitor system memory and swap utilization on Ubuntu Server 20.04

Louis SanchezAugust 15th 2021, 8:55

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 -s

Step 4 : Another handy command is free

free -h

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