linux中top命令_Linux中的top命令指南

linux中top命令

The atop command is a tool for monitoring system resources in Linux. It displays tons of information related to the amount of load on the system’s resources at the process level. There can be indefinite advantages to the user if this utility is mastered.

atop命令是用于监视Linux中的系统资源的工具。 它在流程级别显示大量信息,这些信息与系统资源上的负载量有关。 如果掌握了该实用程序,对用户可能会有无限的好处。

First things first, we have to install the atop command on the system. Debian/Ubuntu users can do so by:

首先,我们必须在系统上安装atop命令。 Debian / Ubuntu用户可以通过以下方式进行操作:


sudo apt install atop

Other Linux users can use their standard package manager, followed by the 'atop' keyword.

其他Linux用户可以使用其标准软件包管理器,后跟'atop'关键字。

This command has the ability to display multiple confidential information related to the system. In order to prevent any data abstraction, we can get elevated access using 'sudo su' or 'sudo -s'. We have complete documentation on sudo.

此命令具有显示与系统有关的多个机密信息的能力。 为了防止任何数据抽象,我们可以使用'sudo su''sudo -s'获得提升的访问权限。 我们有关于sudo的完整文档。

atop命令的基本输出 (Basic Output of the atop Command)

To display all the process-level use of the system’s resources, we can simply run 'atop' in the terminal.

要显示系统资源的所有过程级使用,我们只需在终端中运行'atop'即可。


atop
Atop Basic Output 1
Basic Output of ‘atop’
'atop'的基本输出

As we can see, the whole layout is divided into two panels. The upper panel provides the cumulative use of the system’s resources, whereas the bottom one, displays disintegrated information for each process. Let’s see each of the

如我们所见,整个布局分为两个面板。 上方的面板提供了系统资源的累积使用,而下方的面板显示了每个过程的分解信息。 让我们看看每个

atop命令的累积统计信息 (Cumulative Statistics of the atop command)

Each entry in this view, focuses on a particular system resource.

此视图中的每个条目都集中于特定的系统资源。

1.与过程有关的统计 (1. Process-related Statistics)
  • PRC – stands for “process”.
    • The first two values are the time consumed by the 'sys' (system) and 'user' processes.
    • It is followed by the total number of processes as '#proc'.
    • The next value is the number of threads currently running in the system. ('#trun')
    • '#tslpi' denotes the number of threads that are currently sleeping and interruptible.
    • '#tslpu' denotes the number of threads that are currently sleeping and uninterruptible.
    • The following value is the number of zombie processes.
    • Next up is the number of clone system calls.
    • The last value is the number of processes that ended during the elapsed time. ('#exit')

    PRC –代表“过程”。
    • 前两个值是'sys' (系统)和'user'进程消耗时间
    • 紧随其后的是进程总数 '#proc'
    • 下一个值是系统中当前正在运行的线程数 。 ( '#trun'
    • '#tslpi'表示当前正在Hibernate且可中断线程数。
    • '#tslpu'表示当前正在Hibernate且不可中断线程数。
    • 以下值为僵尸进程数量
    • 接下来是克隆系统调用的数量。
    • 最后一个值是在经过的时间内结束 的进程数 。 ( '#exit'
2.与绩效有关的统计 (2. Performance-related Statistics)
  • CPU – relates to CPU utilization.
    • The first two values show the percentage utilization of all the cores by the system and user processes.
    • The percentage of CPU used for interrupt requests. ('irq')
    • The next value is the idle percentage for all the cores combined.
    • The following value denotes the waiting each CPU core had to do.
    • Next up is the percentage for the steal time.
    • 'guest' denotes the guest-percentage, which is the CPU time spent on other virtual machines.
    • The last two values indicate the current frequency of the CPU.

    CPU –与CPU利用率有关。
    • 前两个值显示系统和用户进程对所有核心的利用率百分比
    • 用于中断请求的CPU百分比。 ( 'irq'
    • 下一个值是所有组合内核的空闲百分比
    • 以下值表示每个CPU内核必须等待的时间
    • 接下来是偷窃时间的百分比
    • 'guest'表示来宾百分比 ,这是在其他虚拟机上花费的CPU时间。
    • 最后两个值指示CPU的当前频率
  • Now, the 'atop' displays the above statistics for each core independently.

    现在, 'atop'独立显示每个内核的上述统计信息。
  • CPL – refers to as CPU Load.
    • The first three values are the average loads with different periods: 1, 5, and 15 minutes.
    • This is followed by the number of context switches ('csw')
    • Next up is the number of interrupts ('intr')
    • The last value is number of available CPUs.

    CPL –指CPU负载。
    • 前三个值是不同时间段的平均负载 :1、5和15分钟。
    • 紧随其后的是上下文切换次数'csw'
    • 接下来是中断数'intr'
    • 最后一个值是可用CPU的数量
3.内存相关统计 (3. Memory-related Statistics)
  • MEM – Memory Utilization
    • The total physical memory supported.
    • The memory currently free.
    • The current cache memory.
    • 'buff' as in “buffer” is the amount of memory consumed in filesystem meta-data.
    • The sum of memory for kernel’s memory allocation shown as 'slab'.
    • The amount of shared memory.

    MEM –内存利用率
    • 支持的总物理内存
    • 内存当前可用
    • 当前的高速缓存内存
    • “缓冲区”中的“ 'buff' ”是文件系统元数据中消耗的内存量
    • 内核的内存分配的内存总和显示为'slab'
    • 共享内存
  • SWP – Swap Memory.

    SWP –交换内存。
3.磁盘相关统计 (3. Disk-related Statistics)
  • DSK – Disk usage
    • The first value denotes the percentage of time the system is busy handling requests.
    • The reading requests issued.
    • The writing requests issued.
    • The rate at which data (in KB) is read per reading request.
    • The rate at which data (in KB) is written per writing request.
    • The next two values are time rates for reading and writing on the disk in Megabytes.
    • The last value is the average number of milliseconds spent in handling requests.

    DSK –磁盘使用率
    • 第一个值表示系统忙于处理请求的时间百分比
    • 发出了阅读请求
    • 发出书面要求
    • 每个读取请求读取数据的速率(以KB为单位)。
    • 每个写入请求写入数据的速率(以KB为单位)。
    • 接下来的两个值是在磁盘上进行读写的 时间速率 ,以兆字节为单位。
    • 最后一个值是处理请求所花费的平均毫秒数
4.与网络有关的统计 (4. Network-related Statistics)
  • NET – Network Statistics at the Transport Layer
    • 'transport' signifies the Transport layer in Networking, which deals with the data protocols.
    • The number of segments received by the system following the TCP protocol. ('tcpi')
    • The number of segments transmitted. ('tcpo')
    • The similar statistics for UCP protocol. ('udpi' for UDP in) and ('udpo' for UDP out).
    • 'tcpao' is the number of active TCP open connections.
    • Opposite to previous 'tcppo' is the number of passive TCP connections, but still open.
    • The figure of TCP retransmissions as 'tcprs'.
    • The figure of UDP input errors as 'udpie'.

    NET –传输层的网络统计
    • 'transport'表示网络中的传输层 ,它处理数据协议。
    • 系统遵循TCP协议接收数。 ( 'tcpi'
    • 传输'tcpo'
    • UCP协议的类似统计信息。 ( 'udpi'用于UDP输入)和( 'udpo'用于UDP输出)。
    • 'tcpao'活动的TCP打开连接的数量。
    • 与以前的'tcppo'相对的是被动TCP连接的数量,但仍处于打开状态。
    • TCP重传的数字为'tcprs'
    • UDP输入错误的数字为'udpie'
  • NET – Network Statistics at the Network Layer
    • 'network' signifies the Network Layer, which deals with Internet Protocols, IPv4 and IPv6 combined.
    • The number of IP packets received by the network interfaces. ('ipi')
    • The number of IP packets transmitted out from the interfaces. ('ipo')
    • The quantity of IP packets forwarded to other interfaces. ('ipfrw')
    • The quantity of IP packets delivered. ('deliv')
    • The last two entries are the number of ICMP packets received and transmitted by the network interfaces.

    NET –网络层的网络统计
    • 'network'表示网络层 ,它处理Internet协议,IPv4和IPv6的组合。
    • 网络接口接收到的IP数据包数。 ( 'ipi'
    • 从接口发送出去的IP报文数。 ( 'ipo'
    • 转发到其他接口的IP数据包的数量。 ( 'ipfrw'
    • 传送IP数据包的数量。 ( 'deliv'
    • 最后两个条目是网络接口接收和发送ICMP数据包的数量。
  • The following lines refer to each active network interface.
    • The first value is the name of the network interface, like 'wlp19s0'.
    • The following two packets are the number of packets that were received and transmitted through the particular interface. ('pcki' and 'pcko')
    • The network speed in Megabits (Mbps) as 'sp'.
    • The rate at which bits are received and transmitted per second. ('si' and 'so')
    • The number of errors in packets received and transmitted. ('erri' and 'erro').
    • The last two values are the dropped packets in both ways. ('drpi' and 'drpo')

    以下各行涉及每个活动的网络接口。
    • 第一个值是网络接口的名称 ,例如'wlp19s0'
    • 以下两个数据包是通过特定接口接收和传输数据包的数量。 ( 'pcki''pcko'
    • 'sp'网络速度,以兆位(Mbps)为单位。
    • 每秒接收和发送 速率 。 ( 'si''so'
    • 接收和发送的数据包中的错误'erri''erro' )。
    • 最后两个值都是两种方式丢弃的数据包 。 ( 'drpi''drpo'

This concludes the explanation of the top panel of the atop command.

到此结束对atop命令顶部面板的说明。

每个过程的系统资源 (System Resources for each process)

It is worth noticing that the values in 'atop' command keeps updating after certain time intervals.

值得注意的是, 'atop'命令中的值在一定时间间隔后会不断更新。

The generic output of the 'atop' command displays the following details for each process entry:

'atop'命令的常规输出为每个进程条目显示以下详细信息:

  • PID – The process ID.

    PID进程ID
  • SYSCPU – The amount of CPU consumed by the process while system handling.

    SYSCPU系统处理过程中进程消耗CPU数量
  • USRCPU – The amount of CPU consumed by the process, during its running in user mode.

    USRCPU –进程在用户模式下运行期间消耗CPU数量
  • VGROW – The amount of virtual memory that the process has occupied since the last value update.

    VGROW –自上次更新以来,该进程已占用虚拟内存量。
  • RGROW – The amount of resident (physical) memory grown since last value update.

    RGROW –自上次值更新以来增长常驻(物理)内存量。
  • RDDSK – The size of data transferred during disk reads.

    RDDSK磁盘读取期间传输的数据大小。
  • WRDSK – The size of data transferred during disk writes.

    WRDSK磁盘写入期间传输的数据大小。
  • RUID – The real user ID under which the process is being executed.

    RUID –执行过程所依据的真实用户ID
  • EUID – The effective user ID under which the process is being executed.

    EUID –执行过程所依据的有效用户ID
  • ST – The current status of the process.

    ST –流程的当前状态
  • EXC – The exit code after the process terminates

    EXC –进程终止后的退出代码
  • THR – The number of threads within the process.

    THR –进程中的线程数
  • S – The current status of the primary thread of the process.

    S –进程主线程的当前状态
  • CPU – The percentage of CPU utilization of the entire process.

    CPU –整个进程的CPU利用率百分比
  • CMD – The name of the process.

    CMD流程名称

In this generic output, the processes are sorted on the basis of percentage CPU utilization. As we can see, in this particular output, we get small amount of information for every type of system resource.

在此通用输出中,将根据CPU利用率百分比对进程进行排序。 如我们所见,在此特定输出中,对于每种类型的系统资源,我们都会获得少量信息。

Let us try to study process-level information for each type of system resource.

让我们尝试研究每种系统资源的过程级信息。

atop命令的基于内存的输出 (The memory-based output of the atop command)

The 'atop' command provides the opportunity to study the memory consumption for each process running in the system. We can do so by running:

'atop'命令提供了研究系统中运行的每个进程的内存消耗的机会。 我们可以这样运行:


atop -m
Atop Memory Output
Memory-based output
基于内存的输出

As we can see, the top panel remains constant even if we added the memory option, '-m'. Let us now understand the columns for each process entry.

如我们所见,即使我们添加了内存选项'-m' ,顶部面板也保持不变。 现在让我们了解每个流程条目的列。

  • PID – The process ID.

    PID进程ID
  • TID – The thread ID.

    TID线程ID
  • MINFLT – The number of minor page faults that have been solved by accessing data from free pages.

    MINFLT –通过访问空闲页面中的数据已解决的次要页面错误数。
  • MAJFLT – The number of major page faults that have been solved by especially retrieving data from disk.

    MAJFLT –通过特别从磁盘检索数据已解决的主要页面错误数。
  • VSTEXT – The virtual memory occupied by the process text.

    VSTEXT –进程文本占用的虚拟内存
  • VSLIBS – The virtual memory occupied by the shared libraries of the process.

    VSLIBS –进程的共享库占用的虚拟内存
  • VDATA – The virtual memory size of the private data of the process.

    VDATA –进程专用数据虚拟内存大小。
  • VSTACK – The virtual memory size of the private stack of the process.

    VSTACK-进程专用堆栈虚拟内存大小。
  • VSIZE – The total virtual memory size of the process.

    VSIZE –进程的总虚拟内存大小。
  • RSIZE – The total resident memory occupied by the process.

    RSIZE –进程占用的总驻留内存
  • MEM – The percentage of RAM consumed by the process.

    MEM –进程消耗的RAM百分比

The processes are sorted with respect to the 'MEM' column.

相对于'MEM'列对过程进行排序。

Since, 'atop' is somewhat an interactive command utility, we can alter the columns from within itself. All we have to do is type the specific option while it is displaying information.

由于'atop'在某种程度上是一种交互式命令实用程序,因此我们可以在其内部更改列。 我们要做的就是在显示信息时键入特定选项。

For instance, after running 'atop' on the terminal, we can switch to memory-specific output by just typing 'm'.

例如,在终端上运行'atop'后,我们只需键入'm'就可以切换到特定于内存的输出。

在Linux中使用atom命令的磁盘特定输出 (Disk-specific output using the atom command in Linux)

To extract information related to disk utilization, we can use the '-d' option along with 'atop' command.

要提取与磁盘利用率有关的信息,我们可以使用'-d'选项和'atop'命令。


atop -d
Atop Disk New
Disk-specific output
磁盘特定的输出

There is not a lot of stuff to notice in the disk-specific output. Some of the key findings are:

在特定于磁盘的输出中没有太多需要注意的东西。 一些主要发现是:

  • RDDSK – The size of data transferred during disk reads.

    RDDSK磁盘读取期间传输的数据大小。
  • WRDSK – The size of data transferred during disk writes.

    WRDSK磁盘写入期间传输的数据大小。
  • WCANCL – The size of data initially written, but later withdrawn

    WCANCL –最初写入但后来撤回数据大小
  • DSK – The percentage of Disk occupied.

    DSK磁盘 占用 百分比
  • CMD – The name of the process.

    CMD –流程的名称

It must be noted that, the processes are sorted on the bases of 'DSK' column.

必须注意的是,这些过程基于'DSK'列进行排序。

使用atop命令查找在后台运行的命令 (Find Commands Running in the Background with atop command)

This gives us the commands that are running in the background as processes in a command-line output format.

这为我们提供了作为命令行输出格式在后台运行的命令。


atop -c
Atop Command Line 1
Command-line for each process
每个过程的命令行

If you copy-paste the lines under the command line column, you can re-run the same process. This output tells us exactly what command was run in the background to initiate the process.

如果将命令行行下的行复制粘贴,则可以重新运行相同的过程。 此输出准确地告诉我们在后台运行了什么命令来启动该过程。

基于线程的信息 (Thread-based Information)

Instead of just inspecting process information, atop command provides the ability to check for thread-specific resource utilization. To access this output we can either run:

atop命令不仅可以检查进程信息,还可以检查特定于线程的资源利用率。 要访问此输出,我们可以运行:


atop -y

or just press 'y' key when the command is already displaying system resource information.

或者在命令已经显示系统资源信息时按'y'键。

Atop Thread Info
Thread-specific output
特定于线程的输出

It is clear that none of the system resource columns have changed. All that has been added is the thread count of their respective process.

显然,系统资源列均未更改。 添加的只是它们各自进程的线程计数。

杂项信息 (Miscellaneous information )

There can numerous kinds of information that can be extracted using the 'atop' command. Some of the useful ones are:

可以使用'atop'命令提取多种信息。 一些有用的是:

1.查找流程开始时间 (1. Find process start-times)

Using the '-v' option, we can get process characteristics.

使用'-v'选项,我们可以获得过程特征。


atop -v
Atop Start Time
Process start-times
流程开始时间

2.系统中每个用户的进程数 (2. Number of processes for each user in the system)


atop -au
Atop Users Edited
User-based processes
基于用户的流程

3.流程在哪个核心上工作? (3. Which core a process is working on?)

This specific kind of information comes under scheduling characteristics for a process. It can be accessed by using '-s' option.

这种特定类型的信息属于流程的调度特性。 可以使用'-s'选项进行访问。


atop -s
Atop User Processes 1 1
Core number for each process
每个进程的核心编号

很少“顶”花样 (Few ‘atop’ tricks)

There are certain 'atop' command tricks that might be useful:

有一些'atop'命令技巧可能会有用:

  • Pausing the 'atop' screen – using 'z' key.

    暂停'atop'屏幕-使用'z'键。
  • Changing the time interval of value updates – using ‘i' key followed by the number of seconds, we wish to change it to.

    更改值更新的时间间隔–我们希望使用' i'键和秒数来更改它。
  • Interrupt to instantly update the values – using 't' key.

    使用't'键中断以立即更新值。
  • Quitting the display – using 'q' key.

    退出显示–使用'q'键。

结论 (Conclusion)

We know that 'atop' command can be too much to handle for any Linux user. It takes patience and perseverance to learn about this brilliant command. For any queries, feel free to ping us down in the comments section.

我们知道, 'atop'命令对于任何Linux用户来说都太多了。 了解这一出色的命令需要耐心和毅力。 如有任何疑问,请随时在评论部分中对我们进行查询。

翻译自: https://www.journaldev.com/41719/atop-command-in-linux

linux中top命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值