Top: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 31: Line 31:
total = free + used + buff/cache
total = free + used + buff/cache
</syntaxhighlight>
</syntaxhighlight>
Virtual memory summary information:
      Line 2 reflects mostly virtual memory, classified as:
          total, free, used and avail (which is physical memory)
      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
      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.
      In the alternate memory display modes, two abbreviated summary lines are shown consisting of these elements:
                      a    b          c
          GiB Mem : 18.7/15.738  [ ...
          GiB Swap:  0.0/7.999    [ ...


=Linux=
=Linux=

Revision as of 03:19, 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

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