How to monitor resource usage

This article describes how to monitor resource usage using the top and atop commands.

Method #1: Using 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:


By default, top updates the displayed information every 3 seconds. There are many commands for manipulating the information that top displays. For example, to sort tasks by CPU usage, type P.

To view detailed information about using the top command, type the following command:

man top

Method #2: Using 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:


When you start atop for the first time, the amount of information displayed can be a little overwhelming. Here is a quick summary of the information atop displays:

  • 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 (cpuXXX w).
  • 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.

To view complete reference information for the atop command, type the following command:

man atop
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:

atop -r

After atop loads the server history, you can move forward through the history by typing t (lowercase t). Note that the time at the top of the screen moves forward. To move backward through the history, type 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:

atop -r -b 10:15

To view resource usage for days in the past, list the files in the /var/log/atop directory to see which days are available. Then start atop using the -r option and the specified log file. For example, the following command instructs atop to load resource usage data for June 16, 2013:

atop -r /var/log/atop/atop_20140316

To quickly and easily view resource usage information for yesterday, type the following command:

atop -r y

Similarly, to view resource usage information for the day before yesterday, type the following command:

atop -r yy

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.