Method #1: Use the top command
The traditional way of viewing resource usage information on Linux is to use the top program. The top program provides a real-time view that includes system information and a list of running processes. You can also customize which information top displays. To start top, log in to your account using SSH, and then type the following command:P.
To view detailed information about using the top command, type the following command:
Method #2: Use the atop command
The atop program is similar to the well-known top program, but it has many extra features. Like top, atop displays a real-time summary of the system’s resource usage. However, atop displays more detailed information, as well as several ways to view and filter that information. Additionally, atop runs a background process that maintains system activity log files. You can access these system activity logs in atop to view past resource usage information. To start atop, log in to your account using SSH, and then type the following command:- The top line displays the server name, as well as the date and time of the last data sample.
- The PRC row displays general statistics, such as time spent in system calls (sys) and user space (user). This line also displays the total number of processes (#proc) and zombie processes (#zombie).
- The CPU and cpu rows display statistics for each CPU. Each row shows the percentage of time a CPU has spent doing various tasks such as system calls (sys), user space processing (user), servicing hardware interrupts (irq), doing nothing (idle), and waiting for disks (cpuXXXw).
- The CPL row displays the weighted load average for the past 1, 5, and 15 minutes. It also shows the number of context switches (csw). Context switches occur when the processor switches between kernel space and user space.
- The MEM row displays memory usage information.
- The SWP row displays swap memory usage information.
- The PAG row displays paging memory frequency, and should appear rarely on a healthy server.
- The DSK row displays disk usage information.
- The NET rows display usage statistics for each network interface.
View server activity history
The atop program maintains activity logs for the past few days. If your web site started experiencing problems yesterday, for example, you could load yesterday’s resource usage data into atop and view what was happening on the system at the time. To view the server’s activity for today, type the following command:T (uppercase T).
To view the server history starting at a specific time, start atop with the -b option. For example, to view the server activity for today starting at 10:15, type the following command: