This article describes how to monitor resource usage using the top and atop commands.
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:
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:
To view complete reference information for the atop command, type the following command:
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:
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
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.