Top: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 6: Line 6:
=Overview=
=Overview=


Display per VM information and per process information.
Display per host/VM/container information and per process information.


<pre>
<syntaxhighlight lang='text'>
top - 14:44:47 up 4 min,  1 user,  load average: 0.00, 0.01, 0.01
top - 14:44:47 up 4 min,  1 user,  load average: 0.00, 0.01, 0.01
Tasks:  87 total,  2 running,  85 sleeping,  0 stopped,  0 zombie
Tasks:  87 total,  2 running,  85 sleeping,  0 stopped,  0 zombie
Line 16: Line 16:


PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM    TIME+ COMMAND
PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM    TIME+ COMMAND
    1 root      20  0  201660  3932  2412 S  0.0  0.4  0:00.48 systemd
1   root      20  0  201660  3932  2412 S  0.0  0.4  0:00.48 systemd
    2 root      20  0      0      0      0 S  0.0  0.0  0:00.00 kthreadd
2   root      20  0      0      0      0 S  0.0  0.0  0:00.00 kthreadd
</pre>
</syntaxhighlight>


Memory summary information:
The memory summary line ("KiB Mem") refers to the entire host/VM/container, as follows:
* total physical memory. The same value as [[Proc-meminfo#MemTotal|/proc/meminfo MemTotal]].
* total physical memory. The same value as [[Proc-meminfo#MemTotal|/proc/meminfo MemTotal]].
* free physical memory. The same value as [[Proc-meminfo#MemFree|/proc/meminfo MemFree]].
* used physical memory. The memory is used by process, but not in buffers and cache.
* buffers/cache physical memory. The represents the sum of [[Proc-meminfo#Buffers|/proc/meminfo Buffers]] and [[Proc-meminfo#Cached|/proc/meminfo Cached]].


      As a default, Line 1 reflects physical memory, classified as:
The relationship between the values described above is given by the formula:
          total, free, used and buff/cache


      Line 2 reflects mostly virtual memory, classified as:
<syntaxhighlight lang='text'>
          total, free, used and avail (which is physical memory)
total = free + used + buff/cache
</syntaxhighlight>


      The avail number on line 2 is an estimation of physical memory available for starting new applications, without swapping.  Unlike the free field, it attempts  to  account
The metrics per process are:
      for readily reclaimable page cache and memory slabs.  It is available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free.
* <span id='VIRT'></span>VIRT: [[Linux_Memory_Management#Virtual_Size_of_a_Process|virtual size of the process]].
 
* <span id='RES'></span>RES: [[Linux_Memory_Management#Resident_Size_of_a_Process|resident size of the process]].
      In the alternate memory display modes, two abbreviated summary lines are shown consisting of these elements:
* <span id='SHR'></span>SHR: [[Linux_Memory_Management#Shareable_Size_of_a_Process|shareable size of the process]].
                      a    b          c
          GiB Mem : 18.7/15.738  [ ...
          GiB Swap: 0.0/7.999    [ ...


=Linux=
=Linux=

Latest revision as of 03:25, 29 December 2020

Internal

Overview

Display per host/VM/container information and per process information.

top - 14:44:47 up 4 min,  1 user,  load average: 0.00, 0.01, 0.01
Tasks:  87 total,   2 running,  85 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.5 us,  0.5 sy,  0.0 ni, 98.8 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1017160 total,   787000 free,    88844 used,   141316 buff/cache
KiB Swap:  1048572 total,  1048572 free,        0 used.   793204 avail Me

PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
1   root      20   0  201660   3932   2412 S  0.0  0.4   0:00.48 systemd
2   root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd

The memory summary line ("KiB Mem") refers to the entire host/VM/container, as follows:

The relationship between the values described above is given by the formula:

total = free + used + buff/cache

The metrics per process are:

Linux

Batch Mode

Run "top" in batch mode, just one iteration:

top -b -n 1

Only summary information (and one process for PID 0)

top -b -n 1 -p 0

Mac

Batch Mode

Specify one sample:

top -l 1

-l logging mode.

Get stats only for specific keys: -o <key>, where keys: ...

-n <nprocs> display only up to nprocs. 0 works, it only displays the system-wide stats.

top -l 1 -n 0