Top: Difference between revisions
Jump to navigation
Jump to search
(14 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
Display per host/VM/container information and per process information. | |||
<syntaxhighlight lang='text'> | |||
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 | |||
</syntaxhighlight> | |||
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]]. | |||
* 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]]. | |||
The relationship between the values described above is given by the formula: | |||
<syntaxhighlight lang='text'> | |||
total = free + used + buff/cache | |||
</syntaxhighlight> | |||
The metrics per process are: | |||
* <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]]. | |||
* <span id='SHR'></span>SHR: [[Linux_Memory_Management#Shareable_Size_of_a_Process|shareable size of the process]]. | |||
=Linux= | =Linux= | ||
Line 14: | Line 45: | ||
<pre> | <pre> | ||
top -b -n 1 | top -b -n 1 | ||
</pre> | |||
Only summary information (and one process for PID 0) | |||
<pre> | |||
top -b -n 1 -p 0 | |||
</pre> | </pre> | ||
Line 31: | Line 68: | ||
-n <nprocs> display only up to nprocs. 0 works, it only displays the system-wide stats. | -n <nprocs> display only up to nprocs. 0 works, it only displays the system-wide stats. | ||
<pre> | |||
top -l 1 -n 0 | |||
</pre> |
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:
- total physical memory. The same value as /proc/meminfo MemTotal.
- free physical memory. The same value as /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 and /proc/meminfo Cached.
The relationship between the values described above is given by the formula:
total = free + used + buff/cache
The metrics per process are:
- VIRT: virtual size of the process.
- RES: resident size of the process.
- SHR: shareable size of the process.
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