Introduction to atop tool
Atop is a tool dedicated to monitoring Linux system resources and processes. It records system and process activity, reporting on the status of all running processes. Data collected includes resource usage (CPU, memory, disk, network) and process states, which can be saved as log files. For each process, we obtain key information such as CPU utilization, memory growth, disk usage, priority, username, status, and exit code. Furthermore, through the Atop configuration file, users can customize parameters like logging frequency, storage path, and rotation policy.
Installing atop tool
Installation methods for atop vary slightly across different Linux distributions; the following explanation uses a common operating system as an example
- Alibaba Cloud Linux 3/2、CentOS 7/8、Fedora、Rocky Linux 9:
- Execute installation command:
- Start atop service:
- Ubuntu / Debian:
- Update software source list:
- Execute installation command:
- Start atop service:
- CentOS Stream 9:
- Download and install:
- Start atop service:
- openSUSE:
- Execute installation command:
- Start atop service:
If your operating system distribution is not listed above, please visit the atop official website for installation information
Configure monitoring cycle and log retention time
- In Alibaba Cloud Linux 3/2, CentOS 7/8, and Fedora systems, the atop configuration file is __;在Ubuntu、Debian和openSUSE系统中,配置文件是__INLINE_CODE_1
- Please provide the Chinese text you want me to translate. I am ready when you are!
- Used to control log file recording options; defaults to empty
- Monitoring cycle, default 600 seconds. To collect historical logs for troubleshooting, adjust this frequency as needed.
- Log retention period, default 28 days
- It appears you’ve provided a string of formatting codes rather than actual Chinese text. Without the Chinese characters, I cannot translate. Please provide the Chinese text you want translated.
- Please provide the Chinese text you want me to translate. I am ready when you are!
- Execute command to open configuration file:
- On Alibaba Cloud Linux 3/2, CentOS 7/8, and Fedora systems:
- In Ubuntu, Debian, openSUSE, CentOS Stream 9, Rocky Linux 9 systems:
- Enter edit mode by pressing INLINE_CODE_0, then adjust the configuration parameters as needed. For example, change the monitoring cycle to 30 seconds, set the log retention time to 7 days, and keep the default log path:
- Press, save, and exit editing
- Restarting the atop service applies the configuration
LOGOPTS=""
LOGINTERVAL=30
LOGGENERATIONS=7
LOGPATH=/var/log/atop
Using the atop tool
- The following are common commands in interactive command mode:
- Switch back to the default combined output view
- Display the full command line of processes
- Sort by process memory usage in descending order
- Sort processes by disk usage in descending order
- Sort by process resource utilization in descending order
- Sort by process network usage in descending order
- Go to the next monitoring point
- Go to the previous monitoring point
- It appears you’ve provided a string of formatting codes rather than actual Chinese text. Without the Chinese characters, I cannot translate. Please provide the Chinese text you want translated.
- Please provide the Chinese text you want me to translate. I am ready when you are!
- Hostname, information sampling date and time
- Overall process runtime information, including kernel and user space execution time, total number of processes, and the count of processes in different states
- Overall CPU utilization, the sum of values for each field equals INLINE_CODE_0 (N being the number of CPU cores), including kernel time, user time, interrupts, idle time, and wait for disk I/O
- CPU load information, such as the average number of processes in the run queue over the past 1, 5, and 15 minutes, context switch count, and interrupt occurrence count
- Memory usage, including total physical memory, idle memory, page cache memory, file cache memory, and kernel occupied memory
- Swap space usage, including total swap area and free swap space size
- Virtual memory paging information, such as page swap in and swap out counts
- Disk usage, with each disk device represented by a column, displaying device identifier, busy time ratio, and read/write request count
- Network conditions, displaying receive and send packet sizes for TCP/UDP, IP layer, and active network interfaces
- Please provide the Chinese text you want me to translate. I am ready when you are!
- Check system metrics every 5 seconds
- Check system metrics within the next 5 minutes (30 times, 10-second intervals): INLINE_CODE_0
- Check system metrics 10 minutes after the current time (10 times, with 60-second intervals) and write the results to a file: INLINE_CODE_0
- After 查看历史指标日志 starts, log records are saved by default in the
/var/log/atopdirectory. When viewing, ensure the log file for the specified date exists, otherwise an error will occur.
- View daily history indicator logs
- View yesterday’s historical metric logs:
- View historical metric logs for a specified date, such as November 6, 2024
- View historical indicator logs from a specified time within a designated date range, such as from 2:00 PM on November 6, 2024
- View historical indicator logs for a specified date and time period, such as from 00:04 to 00:08 on November 5, 2024
- Please provide the Chinese text you want me to translate. I am ready when you are!
- View the CPU utilization report for the current system over 1 minute (12 times, with 5-second intervals): INLINE_CODE_0
- View memory indicator reports for a specified time period on a given day, such as 18:00 to 18:01
- View memory metrics reports for specified dates and time periods, such as 6:00 PM to 6:01 PM on November 5, 2024
Other Operations
- To generate an atop index log file daily, you can do the following:
- Adjust monitoring cycle, log retention time, and log storage path as needed
- Start the daily log rotation service and enable it to start automatically at boot
- If the business has more complex requirements for log processing, it can be combined with logrotate or custom scripts to implement log management
- If network usage monitoring is required, you can install the netatop module (which is not installed by default in atop). For example, using Alibaba Cloud Linux 3 system:
- Install the kernel development package and software environment required for compilation
- Download the latest version of netatop source code to the designated directory
- Unzip the source code and enter the source directory: INLINE_CODE_0
- Build and install modules and daemons from source code
- Start netatop service:
The atop tool is powerful and flexible. With proper installation, configuration, and usage, we can better understand the status of a Linux system, promptly identify and resolve potential issues. We hope this article helps everyone improve their Linux system monitoring skills.
References
- Please provide the Chinese text you want me to translate. I am ready when you are! Just paste the text here.
- Please provide the Chinese text you want me to translate. I am ready when you are! Just paste the text here.