How can I use the atop tool to get historical utilization stats for processes on my EC2 Linux instance?
5 minute read
I want to monitor historical resource usage on my Amazon Elastic Compute Cloud (Amazon EC2) instance. How can I use the atop tool to do this?
The atop tool is a performance monitoring tool that records historical resource usage for later analysis. This tool can also do real-time reporting. You can retrieve usage for CPU utilization, memory consumption, and disk I/O for each process and thread. The atop tool stays active as a background service while it records the stats, allowing for long-term server analysis. The stats are stored for 28 days, by default.
Note: Atop starts logging data only after it's installed. Historical performance data about processes can't be retrieved before the date of atop's installation.
In the preceding output example, the first recorded snapshot was at 2021/09/02 17:03:44. To move forward to the next snapshot, press the t key (lowercase) on the keyboard. To move back to the previous snapshot, press the T key (uppercase).
To analyze a specific time slot, press the b key and then enter the date and time. The atop tool skips to the time specified in the Enter new time variable:
NET | lo ---- | pcki 2 | pcko 2 | sp 0 Mbps | si 0 Kbps | so 0 Kbps | erro 0 |
Enter new time (format [YYYYMMDD]hhmm):
PID TID RDDSK WRDSK WCANCL DSK CMD 1/4
You can press shortcut keys to view different statistics. The following are example shortcut keys:
Generic info (default).
Network details. This key works only when the netatop kernel module installed.
Full command line per process
You can use the following shortcut keys to sort the list of process:
Network activity. This key works only if the netatop kernel is installed.
The most active system resource (auto mode).
Press the h key to view the help documentation.
The atopsar command
The atopsar command is a feature similar to the traditional UNIX sar command. You can generate various system activity reports using the atopsar command.
The atopsar command uses color coding and (on request) markers to highlight the utilization of a resource. Critical utilization is marked in red and almost critical is marked in cyan.
Using the flag -c in the following example, a report is generated about current CPU utilization of the system. The following example shows two results, one second apart.