Learn a Linux command every day (117): atop

Time:2021-9-6

Command introduction

Atop command is a tool for monitoring Linux system resources and processes. It is not an internal command and needs to be installed.

[[email protected] ~]# atop
-bash: atop: command not found
[[email protected] ~]# yum install atop -y

#Debian && Ubuntu
apt-get install atop

#Fedora
dnf install atop

Atop records the operation status of the system at a certain frequency. The collected data includes the usage of system resources (CPU, memory, disk and network) and process operation, and can be saved in disk in the form of log file. After the server has a problem, we can obtain the corresponding atop log file for analysis. Atop is an open source software.

Syntax format

atop -w  file  [-S] [-a] [interval [samples]]
atop -r [file] [-b [YYYYMMDD]hhmm] [-e [YYYYMMDD]hhmm] [-flags]

Option description

Shortcut keys for process graph

G # default output
M # memory related output
D # disk related output
N # network related output
C # command line output
U # view the corresponding user resource usage
P # displays all information occupancy of each process (disk, MEM, IO)
P (uppercase) # regular matching, showing all matched processes
Q # exit

Application examples

Learn a Linux command every day (117): atop

[[email protected] ~]# atop
ATOP - centos7              2021/03/29  08:33:28              ----------------              10s elapsed
PRC |  sys    0.18s |  user   0.35s  | #proc     95  |  #tslpu     0 |  #zombie    0  | #exit       0  |
CPU |  sys     1% |  user     3%  | irq     0%  |  idle     96% |  wait      0%  | ipc notavail  |
CPL |  avg1    0.27 |  avg5    0.13  | avg15   0.13  |  csw     1088 |  intr     954  | numcpu     1  |
MEM |  tot   972.3M |  free  203.3M  | cache 563.1M  |  buff    2.1M |  slab   83.8M  | hptot   0.0M  |
SWP |  tot     2.0G |  free    2.0G  | swcac   0.0M  |               |  vmcom 266.0M  | vmlim   2.5G  |
NET |  transport    |  tcpi      1  | tcpo       1  |  udpi       1 |  udpo       1  | tcpao      0  |
NET |  network      |  ipi      17  | ipo       3  |  ipfrw       0 |  deliv     17  | icmpo      1  |
NET |  ens33   ---- |  pcki     20  | pcko       5  |  sp    0 Mbps |  si    6 Kbps  | so    1 Kbps  |

   PID SYSCPU  USRCPU RDELAY   VGROW  RGROW   RDDSK  WRDSK  ST  EXC  THR  S CPUNR   CPU CMD         1/1
 18378  0.08s   0.33s  0.11s      0K     0K      0K     0K  --    -    3  S     0    4% python3
 27620  0.04s   0.02s  0.00s      0K     0K     0K     0K  --    -    1  R     0    1% atop
 27664  0.04s   0.00s  0.02s      0K     0K     0K     0K  --    -    1  S     0    0% kworker/0:1
   404  0.02s   0.00s  0.05s      0K     0K      0K     0K  --    -    1  R     0    0% xfsaild/dm-0
   872  0.00s   0.00s  0.00s      0K     0K      0K     0K  --    -    5  S     0    0% tuned
 19670  0.00s   0.00s  0.00s      0K     0K      0K     0K  --    -    1  S     0    0% sshd
   870  0.00s   0.00s  0.00s      0K     0K      0K     0K  --    -    3  S     0    0% rsyslogd
     1  0.00s   0.00s  0.00s      0K     0K     0K     0K  --    -    1  S     0    0% systemd
     6  0.00s   0.00s  0.09s      0K     0K     0K     0K  --    -    1  S     0    0% ksoftirqd/0
     9  0.00s   0.00s  0.29s      0K     0K     0K     0K  --    -    1  R     0    0% rcu_sched
 26820  0.00s   0.00s  0.00s      0K     0K     0K     0K  --    -    1  S     0    0% kworker/0:2
The output information is described in detail below
Atop column: this column displays the host name, information sampling date and time point

PRC column: this column displays the overall operation of the process
Running time of sys and usr field # processes in kernel state and user state
Total number of proc field # processes
Number of zombie field # dead processes
Exit field #atop the number of processes that exited during the sampling period

CPU column: this column displays the usage of the CPU as a whole (that is, the CPU resources of the multi-core CPU as a whole)

When sys and usr fields #r are used to process the CPU, the proportion of CPU time occupied by the process in kernel state and user state
The IRQ field #q indicates the percentage of time that the CPU is used to process interrupts
The idle field #0 indicates the percentage of time the CPU is fully idle
The wait field #0 indicates the percentage of time that the CPU is in the state of "CPU idle due to process waiting for disk IO"

CPU column: this column displays the CPU usage of a certain core

CPL column: this column displays the CPU load
Avg1, avg5, and avg15 fields # the average number of processes in the running queue in the past 1 minute, 5 minutes, and 15 minutes
Number of CSW field # context exchanges
Intr field # interrupt occurrence times

MEM column: this column displays the memory usage
Tot field # total physical memory
Free field # free memory size
The cache field # is used for the memory size of the page cache
The buff field # is used for the memory size of the file cache
The slab field # is the amount of memory occupied by the system kernel

SWP column: this column displays the usage of swap space
Total tot field # swap area
Free field # free swap space size

PAG column: this column displays virtual memory paging
Swin, swout fields # swap in and swap out memory pages

DSK column: this column displays disk usage
SDA field # disk device ID
Busy field # disk busy time ratio
Number of read and write field # read and write requests


Net column: displays network status, including transport layer (TCP and UDP), IP layer and active network port information

XXXI field # number of packets received by each layer or active network port
Xxxo field # number of contracts issued by each layer or active network interface

Learn a Linux command every day (117): atop