Atop is a tool for monitoring Linux system resources and processes. It records the system operation status at a certain frequency, collects the data of system resources (CPU, memory, disk and network) usage and process running status, and stores these information in the disk in the format of log files. You can obtain the corresponding atop log file to analyze an instance issue.
This document introduces how to use the atop monitoring tool with an example of CVM using CentOS 7.9 operating system.
The prompt message
yum install atop -y
Complete!indicates that atop has been successfully installed.
Configure the atop monitoring period and log retention time as described below:
Execute the following command to open the atop configuration file with VIM editor.
Press i to enter the edit mode and modify the configuration below:
LOGINTERVAL=30. This means to modify the monitoring period of 600s by default to a recommended value-30s. You can modify it to other values as needed.
LOGGENERATIONS=7. This means to modify the log retention time of 28 days by default to 7 days. To prevent overmuch disk storage space from being occupied due to the long-term running of atop, it’s recommended to modify it to 7 days. You can modify it to other values as needed.
systemctl restart atop
The launched atop records the collected data in the log file under the
/var/log/atop directory. Please check the required log file name, execute the following command to view the log file, and analyze the data with reference to atop Common Commands and System Resource Monitoring Field Description.
atop -r /var/log/atop/atop_2021xxxx
You can use the following commands to filter the required data after opening the log file:
-c: Filter by CPU utilization of Linux processes in descending order.
-m: Filter by memory usage of Linux processes in descending order.
-d: Filter by disk usage of Linux processes in descending order.
-a: Filter by resource usage of Linux processes in descending order
-n: Filter by network usage of Linux processes in descending order (This command is not supported by default. To use it, you need to install additional kernel modules).
-t: Redirect to the next monitoring data collection spot.
-T: Redirect to the previous monitoring data collection spot.
-b: Specify point in time, in the format YYYYMMDDhhmm.
Some monitoring fields and values are shown below. These values obtained according to the sampling period are only for reference.
The main parameters are as follows:
It is not recommended to run atop for a long time in application environment. You can stop atop after troubleshooting. In CentOS 7 and other upgraded systems, you can execute the following command to stop the atop.
systemctl stop atop