How to monitor swap space usage in Linux
To monitor swap space usage in Linux
In this article we will explain how to monitor swap space usage in Linux. Swap space holds the virtual memory of the system, which is located on the hard drive of the system.
When the physical memory(RAM) available is fully utilized then the dedicated memory called Swap space from the hard drive is allocated to run the applications of the system.
In Linux machine Swap space can be a dedicated Swap partition, which is created during the installation of the Operating System. The Swap partition size allocation is depends on the available RAM memory size.
Eg: For 2GB RAM memory 4GB of Swap partition is recommended.
To check swap space by following Commands
1. Use Swapon command to monitor swap space status
To view summary of swap space usage " --summary" or " &ndash s" option is used to view summary of swap space usage, both the options performs the same process.
[root@linuxhelp~]# swapon &ndash summary
Output:
2. Using /proc/swaps command to monitor swap space status
Proc is referred to as process information pseudo file system
[root@linuxhelp~]# cat /proc/swaps
Output:
3. Using ‘ free’ Command to monitor swap space status
Using -h option in free command is used to display the amount of free and used system memory.
[root@linuxhelp~]# free -h
Output:
4. Using top Command to monitor swap space status
It shows the processor activity of Linux in real time.
[root@linuxhelp~]# top
Output:
5. Using atop Command to monitor swap space status
It is used to monitor reports activities of various processes and displays used and available memory space.
[root@linuxhelp~]# atop
Output:
6. Using htop Command to monitor swap space status
It is used to view the information about memory usage and the processes in interactive mode
[root@linuxhelp~]# htop
Output:
7. Using the Glances Command to monitor swap space status
Glances command displays the information about running processes like storage space, cpu load, memory usage etc.
[root@linuxhelp~]# glances
Output:
8. Using the vmstat Command to monitor swap space status
Vmstat command will displays the information about virtual memory statistics.
[root@linuxhelp~]# vmstat
Output:
so- memory swapped to disk
si - memory swapped from disk
Points to remember
Some Linux machine don’ t have htop, atop, glances and vmstat packages by default . You can install these packages by using yum install.
Example:
[root@linuxhelp~]#yum install htop