All Products
Search
Document Center

Elastic Compute Service:Install, configure, and use the atop tool

Last Updated:Mar 20, 2025

The atop tool monitors Linux resource usage and processes, and records and reports the activities of the operating system and all processes at a specific frequency. If an issue occurs on a Linux Elastic Compute Service (ECS) instance, you can obtain the atop log files and analyze the files. This topic describes how to install, use, and configure the atop tool on a Linux instance.

Introduction

The data collected by the atop tool includes the process running status and resource usage information, such as the CPU utilization, memory usage, disk usage, and network resource usage. The data is stored on a disk in the form of log files. For each process, the atop tool can report information such as CPU utilization, memory usage, disk usage, priority, usernames, status, and exit codes. You can use the atop configuration file to configure parameters, such as the sampling interval of logs, storage path of log files, and log rotation policy.

Install the atop tool

In this example, an ECS instance that runs Alibaba Cloud Linux is used. Perform the following steps:

  1. Connect to the ECS instance.

    For more information, see Use Workbench to connect to a Linux instance over SSH.

  2. Install the atop tool. The command varies based on the operating system of the ECS instance.

    Alibaba Cloud Linux 2 or 3

    1. Run the following command to install the atop tool:

      sudo yum install -y atop
    2. Run the following command to start the atop service:

      sudo systemctl start atop

    CentOS 7 or 8

    1. Run the following command to install the atop tool:

      sudo yum install -y atop
    2. Run the following command to start the atop service:

      sudo systemctl start atop

    Ubuntu or Debian

    1. Run the following command to update the list of all software in the repository:

      sudo apt update 
    2. Run the following command to install the atop tool:

      sudo apt install -y atop
    3. Run the following command to start the atop service:

      sudo systemctl start atop

    CentOS Stream 9

    1. Run the following command to download and install the atop tool:

      sudo wget https://www.atoptool.nl/download/atop-2.11.0-1.el9.x86_64.rpm && sudo rpm -i atop-2.11.0-1.el9.x86_64.rpm
    2. Run the following command to start the atop service:

      sudo systemctl start atop

    Fedora

    1. Run the following command to install the atop tool:

      sudo yum install -y atop
    2. Run the following command to start the atop service:

      sudo systemctl start atop

    openSUSE

    1. Run the following command to install the atop tool:

      sudo zypper install -y atop atop-daemon
    2. Run the following command to start the atop service:

      sudo systemctl start atop

    Rocky Linux 9

    1. Run the following command to install the atop tool:

      sudo wget https://www.atoptool.nl/download/atop-2.11.0-1.el9.x86_64.rpm && sudo rpm -i atop-2.11.0-1.el9.x86_64.rpm
    2. Run the following command to start the atop service:

      sudo systemctl start atop
    Note

    If your ECS instance runs a Linux distribution different from the preceding distributions, obtain the required installation information from the official atop website. For more information, see Download atop.

(Optional) Configure the atop sampling interval and log retention period

To configure the atop sampling interval, log retention period, and log storage path, perform the following steps. Expand the following configuration file section to view information about the configuration file:

Configuration file

In Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, CentOS 7, CentOS 8, and Fedora operating systems, the configuration file of the atop tool is /etc/sysconfig/atop. In Ubuntu, Debian, and openSUSE operating systems, the configuration file of the atop tool is /etc/default/atop. Default content of the configuration file:

LOGOPTS="" LOGINTERVAL=600 LOGGENERATIONS=28 LOGPATH=/var/log/atop

Take note of the following parameters in the configuration file:

  • LOGOPTS: the logging options. You can use this parameter to specify the path in which log files are stored, the log file naming convention, log rotation cycle, and other logging options. By default, this parameter is left empty, which specifies that no additional logging options are used.

  • LOGINTERVAL: the sampling interval. Default value: 600. Unit: seconds.

    Important

    If you want to collect historical logs by using the atop tool to track and identify exceptions, we recommend that you change the sampling interval based on your actual scenarios and business requirements.

  • LOGGENERATIONS: the log retention period. To minimize the disk space occupied by atop log files when atop runs for an extended period of time, the default log retention period is set to 28 days.

  • LOGPATH: the path in which the log files are stored. Default value: /var/log/atop.

  1. Configure the atop sampling interval and log retention period.

    1. Run one of the following commands based on the instance operating system to open the atop configuration file:

      Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, CentOS 7, CentOS 8, or Fedora

      sudo vim /etc/sysconfig/atop

      Ubuntu, Debian, openSUSE, CentOS Stream 9, or Rocky Linux 9

      sudo vim /etc/default/atop
    2. Press the i key to enter Insert mode.

    3. Change the sampling interval, log retention period, and log storage path based on your business requirements. In this example, the sampling interval is changed to 30 seconds, the log retention period is set to 10 days, and the default value of the log storage path is retained.

      LOGOPTS="" LOGINTERVAL=30 LOGGENERATIONS=10 LOGPATH=/var/log/atop
      Important
      • A shorter sampling interval enables sampling at a finer granularity, but increases the I/O burden on the system and results in larger log files. If you use the atop tool in a production environment, specify an appropriate sampling interval based on your business requirements to prevent excessive log files or log records from occupying excessive I/O resources and affecting business operation.

      • A longer log retention period allows you to view earlier historical logs but occupies more disk space. Specify an appropriate log retention period based on your business requirements.

    4. Press the Esc key, enter :wq, and then press the Enter key to save and close the configuration file.

  2. Run the following command to restart the atop service:

    sudo systemctl restart atop

Use the atop tool

When you use the atop tool to monitor Linux metrics, take note of the common commands and resource monitoring fields. Expand the following sections to view more information:

Common commands

After you open a log file, you can run the following commands in interactive mode:

  • g: displays the default generic output.

  • c: displays the command line of the process.

  • m: filters processes by memory usage in descending order.

  • d: filters processes by disk usage in descending order.

  • a: filters processes by overall resource usage in descending order.

  • n: filters processes by network utilization in descending order.

  • t: goes forward to the next monitoring collection point.

  • T: goes back to the previous monitoring collection point.

  • b: specifies a point in time in the YYYYMMDDhhmm format.

Resource monitoring fields

The following figure shows specific monitoring fields and the values of the fields. The values of the fields vary based on the sampling interval. The following figure is provided only for reference.

2023-04-03_17-30-42

The following table describes the fields.

Field (line)

Description

ATOP

The hostname, sampling date, and period of time that elapsed since data was last sampled.

PRC

The overall running status of the processes.

  • sys and user: the periods of time during which processes run in kernel mode and user mode.

  • # proc: the total number of processes.

  • #trun: the number of processes in the running state.

  • #tslpi: the number of processes in the sleeping interruptible state.

  • #tslpu: the number of processes in the sleeping uninterruptible state.

  • #zombie: the number of dead processes.

  • #exit: the number of processes that exited during the atop sampling interval.

CPU

The overall multi-core CPU utilization. The sum of the field values in a CPU line is N × 100%. N is the number of CPU cores.

  • sys or user: the percentage of the time that the CPU spent running processes in kernel mode or user mode.

  • irq: the percentage of the time that the CPU spent processing interrupts.

  • idle: the percentage of the time when the CPU is in the idle state.

  • wait: the percentage of the time that the CPU spent waiting for disk I/O operations to complete.

CPL

The information about the CPU load.

  • avg1, avg5, and avg15: the average numbers of processes in the running queue in the previous 1 minute, 5 minutes, and 15 minutes.

  • csw: the number of context switches.

  • intr: the number of interrupts.

MEM

The memory usage.

  • tot: the total size of physical memory.

  • free: the size of free memory.

  • cache: the size of memory used for page caching.

  • buff: the size of memory used for file caching.

  • slab: the size of memory occupied by the system kernel.

SWP

The swap space usage.

  • tot: the total size of swap space.

  • free: the size of free swap space.

PAG

The virtual memory paging information.

swin and swout: the number of swapped in memory pages and the number of swapped out memory pages.

DSK

The disk usage. Each DSK line corresponds to a single disk. If a device named vdb exists, a DSK line for vdb is added.

  • vda: the device name of a disk.

  • busy: the percentage of the time when the disk is in the busy state.

  • read and write: the number of read requests and the number of write requests.

NET

The NET line indicates the network status, such as the TCP and UDP status at the transport layer, the network status at the IP layer, and the status of each active network port.

  • **** i: the inbound packet size per layer or per active network port.

  • **** o: the outbound packet size per layer or per active network port.

Important

By default, when you run atop commands in the CLI, the interactive mode is used. In interactive mode, you can filter data by using keyboard commands. For example, press the m key to switch to the memory information view. Press the q key to exit interactive mode. For information about the supported commands, see the Command commands section of this topic. You can also press the ? key in interactive mode to obtain more information.

Query real-time system metrics

  • Query system metrics every 5 seconds.

    atop 5
  • Query system metrics 30 times at 10-second intervals within a 5-minute period.

    atop -M 10 30
  • Query system metrics 10 times at 60-second intervals within a 10-minute period and write the results to a file.

    atop -M 60 10 > /log/atop.mem

Query historical metric logs

After the atop service is started, the service collects data and stores the data in a log file. By default, the log file is stored in the /var/log/atop directory. You can run the following commands to query the historical metric logs that match the specified filter conditions.

Note
  • Run the following sample atop -r commands to query metric logs. Do not use a text editor to open the atop log file.

  • When you use the atop tool to query historical metric logs generated on a specific date, make sure that the historical metric logs that you want to query exist in a log file. If no log file contains the historical metric logs, the stat raw file: No such file or directory error message appears.

  • Query the historical metric logs generated on the current day.

    atop -r 
  • Query the historical metric logs generated on the previous day.

    atop -r y
  • Query the historical metric logs generated on a specific date. In this example, the specified date is November 6, 2024.

    atop -r 20241106
  • Query the historical metric logs generated on a specific date starting from a specific point in time. In this example, the specified date is November 6, 2024 and the start time is 14:00.

    atop -r 20241106 -b 14:00
  • Query the historical metric logs generated within a specific time period on a specific date. In this example, the specified date is November 5, 2024 and the time period is from 00:04 to 00:08.

    atop -r 20241105 -b 00:04 -e 00:08

Query the reports of system activities

  • Query the CPU utilization report of the current system 12 times at 5-second intervals within a 1-minute period.

    atopsar -c 5 12
  • Query the memory metric report within a specific time period on the current day. In this example, the time period is from 18:00 to 18:01.

    atopsar -m -b 18:00 -e 18:01
  • Query the memory metric report within a specific time period on a specific date. In this example, the specified date is November 5, 2024 and the time period is from 18:00 to 18:01.

    atopsar -c -r 20241105 -b 18:00 -e 18:01

Related operations

Configure a daily log rotation policy

To generate an atop metric log file every day, perform the following steps:

  1. (Optional) Change the sampling interval, log retention period, and log storage path based on your business requirements. For more information, see the (Optional) Configure the atop sampling interval and log retention period section of this topic.

  2. Run the following command to enable the service related to daily log rotation to start on system startup and start the service:

    sudo systemctl enable --now atop atopacct atop-rotate.timer
Note

In the preceding example, a log file is generated every day. If your business requires more complex processing of logs, you can use the logrotate tool or custom scripts to manage logs.

Load an optional netatop kernel module

To monitor network usage, install the netatop network monitoring module. In this example, Alibaba Cloud Linux 3 is used.

Note

Netatop can collect statistics on TCP and UDP packets sent and received by each process or thread. By default, netatop is not installed in the atop service. If you want to load an optional netatop kernel module in another Linux distribution, refer to the official atop manuals to install the module. For more information, see Module netatop.

  1. Run the following command to install the kernel development package and the software environment required for compilation for the current kernel:

    sudo yum install -y kernel-devel dkms elfutils-libelf-devel
  2. Run the following command to download the latest version of the netatop source code to the specified directory:

    cd /usr/src/ && sudo wget https://www.atoptool.nl/download/netatop-3.2.2.tar.gz --no-check-certificate
  3. Run the following command to decompress the source code and access the source code directory:

    sudo tar -zxvf netatop-3.2.2.tar.gz && cd netatop-3.2.2
  4. Run the following command to build and install the netatop module and the daemon of the module based on the source code:

    sudo make && sudo make install
  5. Run the following command to start the netatop service:

    sudo systemctl start netatop