본문 바로가기

Linux

top command

Kernel 버전

# uname -r
4.19.269-3.ph3

 

운영체제 배포판 버전

# lsb_release -a
Distributor ID: VMware Photon OS
Description:    VMware Photon OS 3.0
Release:        3.0
Codename:       Photon

 

top 명령 버전

# top -v | head -1
  procps-ng 3.3.15

 

시스템 정보 - Overview

# VCSA
top - 05:26:09 up 4 days,  5:56,  1 user,  load average: 0.05, 0.10, 0.09
Tasks: 290 total,   1 running, 289 sleeping,   0 stopped,   0 zombie
%Cpu0  :  73.8/8.7    83[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||                 ] ### --> 't' 누를 때마다 변경
%Cpu1  :  78.7/10.0   89[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||           ]
GiB Mem : 85.8/11.7     [                                                                                                    ] ### --> 'm' 누를 때마다 변경, 'E'를 누르면 scale(KB, MB 등) 변경
GiB Swap:  3.9/25.0     [                                                                                                    ]
 
# VCSA
top - 06:10:36 up 4 days,  6:40,  1 user,  load average: 0.10, 0.07, 0.07
Tasks: 290 total,   1 running, 289 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.7 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.7 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  11995.4 total,    237.8 free,   9703.1 used,   2054.5 buff/cache
MiB Swap:  25592.0 total,  24581.4 free,   1010.6 used.   1661.6 avail Mem
 
# CentOS
top - 01:27:28 up 13:48,  1 user,  load average: 0.00, 0.03, 0.00
Tasks: 316 total,   2 running, 314 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.8 us,  0.4 sy,  0.0 ni, 98.5 id,  0.1 wa,  0.2 hi,  0.0 si,  0.0 st
MiB Mem :   7762.7 total,   4563.1 free,   1380.4 used,   1819.2 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   6114.7 avail Mem

 

시스템 정보 - 현재시간, 컴퓨터 실행시간(uptime)

# uptime
 05:28:43 up 4 days,  5:58,  1 user,  load average: 0.09, 0.11, 0.09
 
# uptime -p
up 4 days, 5 hours, 59 minutes

 

시스템 정보 - load average

# 시스템 부하정도를 나타내는 1분, 5분, 15분 시스템 부하 평균 값 >> EMA(지수 이동 평균값)

# 'R' 실행 중인 프로세스, 'D' 디스크 I/O 처리완료를 기다리는 프로세스

# 단일 Core 기준 1.0이면 1.0 * 100 = 100%, 0.5이면 0.5 * 100 = 50%, 1.7이면 1.7 * 100 = 170%로 부하가 너무 높은 상태

# 멀티 Core 인 경우, 4 Core이면, 4.0이어야 부하가 4.0 * 100 = 400%로 단일 Core마다 100%라는 의미이고, 만약 3.0이면 3/4 이기 때문에 약 75%정도 부하라고 이해할 수 있음 

# VCSA
top - 05:26:09 up 4 days,  5:56,  1 user,  load average: 0.05, 0.10, 0.09

 

시스템 정보 - Task(프로세스)

# 전체 Task 수, 현재 실행 중인 Task 수, Sleep 상태의 Task 수 

# 현재 실행 중인 Task 수 + Sleep 상태의 Task 수가 전체  Task 수는 아니다. I(Idle) 상태의 Task는 제외되기 때문

# VCSA에서는 다르게 계산하는 듯(running+sleeping이 전체 task 수랑 동일)

# stopped 필드는 Signal에 의해서 멈춰있는 상태, 예를 들어 Ctrl + Z 로 현재 프로세스에 Stop Signal을 보낼 수 있음

Tasks: 290 total,   1 running, 289 sleeping,   0 stopped,   0 zombie
 
# ps -eo comm,state
COMMAND         S
systemd         S
kthreadd        S --> Sleeping
rcu_gp          I --> Idle
rcu_par_gp      I
kworker/0:0H-kb I
mm_percpu_wq    I
ksoftirqd/0     S
rcu_sched       I
rcu_bh          I
migration/0     S
cpuhp/0         S
cpuhp/1         S
migration/1     S
ksoftirqd/1     S
kworker/1:0H-kb I
kdevtmpfs       S
netns           I
kauditd         S
khungtaskd      S
oom_reaper      S
writeback       I
kcompactd0      S
ksmd            S
khugepaged      S
crypto          I
kintegrityd     I
kblockd         I
ata_sff         I
edac-poller     I
devfreq_wq      I
watchdogd       S
kswapd0         S
xfsalloc        I
xfs_mru_cache   I
kthrotld        I
irq/24-pciehp   S
irq/25-pciehp   S
irq/26-pciehp   S
irq/27-pciehp   S
irq/28-pciehp   S
irq/29-pciehp   S
irq/30-pciehp   S
irq/31-pciehp   S
irq/32-pciehp   S
irq/33-pciehp   S
irq/34-pciehp   S
irq/35-pciehp   S
irq/36-pciehp   S
irq/37-pciehp   S
irq/38-pciehp   S
irq/39-pciehp   S
irq/40-pciehp   S
irq/41-pciehp   S
irq/42-pciehp   S
irq/43-pciehp   S
irq/44-pciehp   S
irq/45-pciehp   S
irq/46-pciehp   S
irq/47-pciehp   S
irq/48-pciehp   S
irq/49-pciehp   S
irq/50-pciehp   S
irq/51-pciehp   S
irq/52-pciehp   S
irq/53-pciehp   S
irq/54-pciehp   S
irq/55-pciehp   S
acpi_thermal_pm I
ttm_swap        I
irq/16-vmwgfx   S
iscsi_eh        I
kmpath_rdacd    I
nvme-wq         I
nvme-reset-wq   I
nvme-delete-wq  I
scsi_eh_0       S
scsi_tmf_0      I
scsi_eh_1       S
scsi_tmf_1      I
mpt_poll_0      I
mpt/0           I
scsi_eh_2       S
scsi_tmf_2      I
mpt_poll_1      I
mpt/1           I
scsi_eh_3       S
scsi_tmf_3      I
mpt_poll_2      I
mpt/2           I
scsi_eh_4       S
scsi_tmf_4      I
ipv6_addrconf   I
hwrng           S
kdmflush        I
jbd2/dm-0-8     S
ext4-rsv-conver I
haveged         S
systemd-journal S
kworker/1:1H-kb I
systemd-udevd   S
jbd2/sda3-8     S
ext4-rsv-conver I
lvmetad         S
vami-lighttpd   S
kworker/0:1H-kb I
kdmflush        I
kdmflush        I
kdmflush        I
kdmflush        I
jbd2/dm-1-8     S
ext4-rsv-conver I
kdmflush        I
kdmflush        I
jbd2/dm-3-8     S
ext4-rsv-conver I
kdmflush        I
kdmflush        I
kdmflush        I
jbd2/dm-5-8     S
ext4-rsv-conver I
kdmflush        I
kdmflush        I
jbd2/dm-8-8     S
ext4-rsv-conver I
jbd2/dm-9-8     S
ext4-rsv-conver I
kdmflush        I
kdmflush        I
jbd2/dm-4-8     S
ext4-rsv-conver I
jbd2/dm-7-8     S
ext4-rsv-conver I
kdmflush        I
jbd2/dm-10-8    S
ext4-rsv-conver I
kdmflush        I
jbd2/dm-6-8     S
ext4-rsv-conver I
jbd2/dm-11-8    S
ext4-rsv-conver I
jbd2/dm-14-8    S
ext4-rsv-conver I
jbd2/dm-13-8    S
ext4-rsv-conver I
jbd2/dm-15-8    S
ext4-rsv-conver I
jbd2/dm-12-8    S
ext4-rsv-conver I
systemd-resolve S
auditd          S
VGAuthService   S
dbus-daemon     S
irqbalance      S
systemd-logind  S
vmtoolsd        S
observability.l S
none            S
vdtc            S
sshd            S
dnsmasq         S
crond           S
agetty          S
ntpd            S
sendmail        S
vmon            S
statsMonitor    S
capengine       S
kworker/u128:1- I
kworker/1:2-cgr I
vherdrunner     S
systemd-network S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
rsyslogd        S
lwsmd           S
lwregd          S
netlogond       S
lwiod           S
lsassd          S
vmafdd          S
vmdird          S
vmcad           S
envoy           S
envoy           S
envoy           S
envoy-accesslog S
envoy-logwriter S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
pg_archiver     S
postgres        S
rhttpproxy      S
vmware-eam.laun S
lookupsvc.launc S
python          S
python          S
vmware-vapi-end S
vmware-trustman S
kworker/0:2-ata I
vmware-sca.laun S
postgres        S
vmware-stsd.lau S
vmware-cis-lice S
vmon-vapi-provi S
vmware-vpxd-svc S
postgres        S
postgres        S
vmware-hvc.laun S
observability-v S
vmware-infrapro S
postgres        S
vmware-certific S
vsphere-ui.laun S
vmware-topology S
vmware-certific S
kworker/0:0     I
ps              R
postgres        S
vpxd            S
postgres        S
postgres        S
pschealthd      S
vlcm-main       S
postgres        S
vmware-vsm.laun S
vmware-analytic S
vmware-sps.laun S
updatemgr       S
vsanvcmgmtd     S
vstats          S
postgres        S
java            S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
wcpsvc          S
postgres        S
postgres        S
vmware-content- S
postgres        S
vmware-perfchar S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
postgres        S
kworker/u128:2- I
postgres        S
sshd            S
sftp-server     S
postgres        S
postgres        S
sshd            S
bash            S
postgres        S
postgres        S
postgres        S
kworker/1:0-eve I
postgres        S
kworker/0:1-eve I
postgres        S
postgres        S
kworker/u128:0- I
 
# ps --no-header -eo comm,state | grep I | wc -l
78
 
# ps --no-header -eo comm,state | grep S | wc -l
210
 
# ps --no-header -eo comm,state | grep R | wc -l
1
 
top - 05:46:19 up 4 days,  6:16,  2 users,  load average: 0.07, 0.13, 0.10
Tasks: 291 total,   1 running, 289 sleeping,   1 stopped,   0 zombie
 
# Stop Signal을 받은 프로세스는 fg 명령어(Foreground)를 통해 해제 가능

 

시스템 정보 - CPU 사용률

# us : user-mode(높은 우선순위 nice 0 또는 음수)

# sy : kernel-mode

# ni : user-mode(낮은 우선순위 nice 양수), nice가 높다는 것은 우선순위가 낮다는 것

# id : idle(시스템이 얼마나 여유로운지)

# wa : I/O wait(처리완료를 기다린 시간), 이 수치가 높은 경우 Network/Disk IO 처리에 오래 걸린다는 의미

# hi : hard irq (인터럽트 전반부 처리), TH Handler 

# si : soft irq(인터럽트 후반부 처리), BH Handler

# st : 가상 CPU 구동(Guest OS를 위한 VM 처리)

%Cpu0  :  0.7 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.7 us,  0.7 sy,  0.0 ni, 98.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
 
## 위 us, sy, ni, id, wa, hi, si, st를 모두 더하면 100
# python -c "print (1.3+0.7+98.0)"
100.0

 

시스템 정보 - 메모리 사용률

# total : 총 메모리 공간(아래 예제의 단위는 KB), 'E' 를 누르면 Scale 변경

# free : 남는 메모리 공간

# used : 사용 중인 메모리 공간

# buff/cache : 디스크에 있는 내용을 메모리에 캐시한 공간

# available : 프로세스가 처음 시작 시 사용가능한 메모리 공간(회수하면 얻을 수 있는 공간 포함), 따라서 free + cache의 일부분을 포함한 양이 available

# swap : 메모리의 내용을 저장해 둘 수 있는 디스크 공간, 아래 예제에서는 swap 영역 25G 

KiB Mem : 12283268 total,   302356 free,  9839012 used,  2141900 buff/cache
KiB Swap: 26206204 total, 25153608 free,  1052596 used.  1800128 avail Mem
 
## total = free + used + buff/cache
# python -c "print (302356+9839012+2141900)"
12283268
 
# free -h(h는 human-readable)
              total        used        free      shared  buff/cache   available
Mem:           11Gi       9.4Gi       294Mi       406Mi       2.0Gi       1.7Gi
Swap:          24Gi       1.0Gi        23Gi
 
## Swap 영역 확인
# lsblk
NAME                              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                                 8:0    0 48.6G  0 disk
├─sda1                              8:1    0    4M  0 part
├─sda2                              8:2    0   10M  0 part /boot/efi
├─sda3                              8:3     512M  0 part /boot
└─sda4                              8:4    0   48G  0 part
  └─vg_root_0-lv_root_0           254:0    0   48G  0 lvm  /
sdb                                 8:16    5.6G  0 disk
sdc                                 8:32   0   25G  0 disk
└─swap_vg-swap1                   254:2    0   25G  0 lvm  [SWAP] ### <-- !!
sdd                                 8:48   0   25G  0 disk
└─core_vg-core                    254:3    0   25G  0 lvm  /storage/core
sde                                 8:64   0   10G  0 disk
└─log_vg-log                      254:4    0   10G  0 lvm  /storage/log
sdf                                 8:80   0   10G  0 disk
└─db_vg-db                        254:5    0   10G  0 lvm  /storage/db
sdg                                 8:96   0   15G  0 disk
└─dblog_vg-dblog                  254:6    0   15G  0 lvm  /storage/dblog
sdh                                 8:112  0   10G  0 disk
└─seat_vg-seat                    254:7    0   10G  0 lvm  /storage/seat
sdi                                 8:128  0    1G  0 disk
└─netdump_vg-netdump              254:8    0 1016M  0 lvm  /storage/netdump
sdj                                 8:144  0   10G  0 disk
└─autodeploy_vg-autodeploy        254:9    0   10G  0 lvm  /storage/autodeploy
sdk                                 8:160  0   10G  0 disk
└─imagebuilder_vg-imagebuilder    254:10   0   10G  0 lvm  /storage/imagebuilder
sdl                                 8:176   100G  0 disk
└─updatemgr_vg-updatemgr          254:11    100G  0 lvm  /storage/updatemgr
sdm                                 8:192  0   50G  0 disk
└─archive_vg-archive              254:12   0   50G  0 lvm  /storage/archive
sdn                                 8:208  0   10G  0 disk
└─vtsdb_vg-vtsdb                  254:13   0   10G  0 lvm  /storage/vtsdb
sdo                                 8:224  0    5G  0 disk
└─vtsdblog_vg-vtsdblog            254:14   0    5G  0 lvm  /storage/vtsdblog
sdp                                 8:240   100G  0 disk
└─lifecycle_vg-lifecycle          254:15    100G  0 lvm  /storage/lifecycle
sr0                                11:0    1 1024M  0 rom
sdq                                65:0     150G  0 disk
└─vg_lvm_snapshot-lv_lvm_snapshot 254:1     150G  0 lvm  /storage/lvm_snapshot

 

프로세스 세부 정보

# PID : 프로세스 ID

# PR(priority) : 20 + nice

# NI : nice (친절도), 우선순위 반대, 친절도가 높다는 것은 양보를 잘 해준다는 의미

# VIRT : 가상 메모리 공간, SWAP + RES, 모든 코드/데이터/공유 라이브러리/Swap-out된 페이지 및 Mapping 되었지만 사용되지 않은 Page 포함

# RES : 실제 사용 중인 물리 메모리 공간, RSan+RSfd+RSsh, 

# SHR: 공유메모리 공간

# S: 프로세스 상태 (STATE)

    'D' = uninterruptible sleep (예시: 디스크I/O처리대기), "dd if=/dev/zero of=testfile bs=512M count 2000"으로 테스트 할 때, 잠시 확인 가능

    'R' = running

    'S' = sleeping (예시: 네트워크 I/O 처리대기)

    'I' = idle (예시: sleep 중인 kernel thread)

    'T' = stopped by job control signal

## vimtop을 우선 실행하고, vimtop의 PID 확인
# pidof vimtop
46918
 
## vimtop에 stop signal 전송
# kill -s SIGSTOP 46918
 
## top에서 stopped 숫자가 1로 증가한 것을 확인
top - 11:28:50 up 4 days, 11:58,  3 users,  load average: 0.06, 0.08, 0.08
Tasks: 291 total,   1 running, 289 sleeping,   1 stopped,   0 zombie
%Cpu0  :   2.6/0.0     3[|||                                                                                                 ]
%Cpu1  :   2.6/1.3     4[||||                                                                                                ]
KiB Mem : 12283268 total,   234396 free,  9877840 used,  2171032 buff/cache
KiB Swap: 26206204 total, 25154120 free,  1052084 used.  1760656 avail Mem
 
## vimtop 프로세스 상태 확인
# ps -eo comm,state | grep " T"
vimtop          T ### <-- !!
 
## fg 명령어로 복구 가능
# fg (vimtop이 실행 중이던 ssh session에서 실행)

 

    't' = stopped by debugger during trace, GDB 사용 중인 프로세스에서 확인 가능

    'Z' = zombie

'D'상태 태스크는 시그널을 전달해도 wake up 되지 않음
'S'상태 태스크는 시그널을 전달하면 wake up 가능  
 
'D'는 커널내부에서 태스크 상태가 TASK_UNINTERRUPTIBLE 인경우
'S'는 커널내부에서 태스크 상태가 TASK_INTERRUPTIBLE 인경우
 
꼭 디스크, 네트워크 I/O 일때에만 'D', 'S' 상태 인것은 아니고
커널내부에서 특정 조건(예시: I/O처리 완료)이 맞을때 까지 waiting 해야할때 상황에 맞춰서 TASK_INTERRUPTIBLE 또는 TASK_UNINTERRUPTIBLE 로 태스크 상태를 변경해놓고 Sleep
 
보통의 경우는 'D'는 Disk I/O 요청을 기다리는 경우가 많아서 해당 PID가 'D' 상태라면 /proc/[PID]/status 입력시 "State:  D (disk sleep)" 도 확인가능
 
* 참고 명령: 'D' 상태의 task 정보(stacktrace 등) 덤프(dmesg로 확인)
$ echo w > /proc/sysrq-trigger

 

# %CPU: CPU 사용율

# %MEM: 메모리 사용율

# TIME+: 프로그램 실행한시간

  PID USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND
    1 root      20   0   92936   6932   0.0   0.1   0:10.10 S /lib/systemd/systemd --switched-root --system --deserialize 16
 1309 root      20   0    8064   1628   0.0   0.0   0:03.53 S  `- /usr/sbin/haveged -w 1024 -v 1 --Foreground
 1310 root      20    158768  93524   0.0   0.8   1:13.83 S  `- /lib/systemd/systemd-journald
 1333 root      20   0   18364   4856   0.0   0.0   0:00.16 S  `- /lib/systemd/systemd-udevd
 1392 root      20   0 1120648   3172   0.0   0.0   0:00.00 S  `- /usr/sbin/lvmetad -f
 1677 systemd+  20   0   12572   4080   0.0   0.0   0:26.98 S  `- /lib/systemd/systemd-resolved
 1679 root      16  -4   14704   1680   0.0   0.0   0:03.90 S  `- /sbin/auditd
 1700 root      20   0   24008   8160   0.0   0.1   0:00.01 S  `- /usr/bin/VGAuthService -s
 1704 message+  20   0    6336   3684   0.0   0.0   0:58.19 S  `- /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
 1707 root      20   0   82788   3768   0.0   0.0   0:09.40 S  `- /usr/sbin/irqbalance --foreground
 1708 root      20   0    7512   3720   0.0   0.0   0:00.34 S  `- /lib/systemd/systemd-logind
 1720 root      20    255972   8312   0.0   0.1   4:24.85 S  `- /usr/bin/vmtoolsd
 1815 observa+  20   0 1446244  45920   0.0   0.4  12:08.59 S  `- /usr/java/jre-vmware/bin/observability.launcher -Xmx48m -XX:CompressedClassSpaceSize=32m -Xss320k -XX:ParallelGCThreads=4 -Dlog4j2.formatMsgNoLookups=true -Djava.ext.dir+
 1871 vdtc      20    601372   9260   0.0   0.1   0:36.51 S  `- /usr/lib/vmware-vdtc/vdtc
 1872 root      20   0    8256   5128   0.0   0.0   0:00.01 S  `- /usr/sbin/sshd -D
32293 root      20   0    8636   5764   0.0   0.0   0:00.06 S      `- sshd: root@notty
32316 root      20   0    5880   2868   0.0   0.0   0:00.03 S          `- /usr/libexec/sftp-server
23489 root      20   0    8744   6608   0.0   0.1   0:00.07 S      `- sshd: root@pts/0
23523 root      20   0   16988   5184   0.0   0.0   0:00.03 S          `- -bash
37523 root      20   0   15816   3536   0.0   0.0   0:00.35 R              `- top
<snip>

 

# 'P' : CPU 사용량 기준으로 정렬

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
2478 root      20   0 1104460 360984  76520 S   1.7   4.5  22:37.80 kube-apiserver
2425 root      20   0   10.7g  71396  27404 S   1.3   0.9  10:08.19 etcd
1221 root      20   0 1788724 117000  66188 S   1.0   1.5  12:03.78 kubelet
2470 root      20    820960 127332  66740 S   0.7   1.6  13:44.16 kube-controller
1119 root      20   0 2398640  79220  36172 S   0.3   1.0   3:07.02 containerd
3462 root      20    805760 117116  62920 S   0.3   1.5   2:14.67 cilium-agent

 

# 'M' : 메모리 사용량 기준으로 정렬

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
2478 root      20   0 1104460 360984  76520 S   1.3   4.5  22:38.60 kube-apiserver
2017 gdm       20   0 3866784 275484 113252 S   0.0   3.5   0:23.32 gnome-shell
2470 root      20    820960 127332  66740 S   2.2   1.6  13:44.72 kube-controller
3462 root      20    805760 117116  62920 S   0.0   1.5   2:14.77 cilium-agent

 

# 'N' : PID 기준으로 정렬(내림차순)

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
22693 root      20    278404   5304   4232 R   8.7   0.1   0:00.04 top
22690 root      20    217092    836    764 S   0.0   0.0   0:00.00 sleep
22645 root      20   0       0      0      0 I   0.0   0.0   0:00.00 kworker/2:2-events
22616 root      20   0       0      0      0 I   0.0   0.0   0:00.02 kworker/1:1-events_power_efficient
22589 root      20   0       0      0      0 I   0.0   0.0   0:00.00 kworker/u8:2-events_unbound
22548 root      20   0       0      0      0 I   0.0   0.0   0:00.01 kworker/2:0-mm_percpu_wq

 

# 'T' : Running Time 기준으로 정렬

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
2478 root      20   0 1104460 339400  76520 S   0.0   4.3  22:40.40 kube-apiserver
2470 root      20    820960 127332  66740 S   0.0   1.6  13:45.82 kube-controller
1221 root      20   0 1788724 117000  66188 S   1.2   1.5  12:05.22 kubelet
2425 root      20   0   10.7g  71656  27404 S   0.0   0.9  10:09.38 etcd
1119 root      20   0 2398640  79240  36172 S   0.0   1.0   3:07.38 containerd

 

# 'R' : 오름차순/내림차순 변경

# 아래 예제는 PID로 정렬하고 나서 Default 내림차순에서 'R'을 눌러 오름차순으로 변경 

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  1 root      20    238712  11408   8268 S   0.0   0.1   0:02.65 systemd
  2 root      20   0       0      0      0 S   0.0   0.0   0:00.02 kthreadd
  3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
  4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp
  6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-events_highpri

 

# 'H' : 쓰레드 기준으로 출력

top - 07:56:11 up 20:17,  1 user,  load average: 0.12, 0.07, 0.01
Threads: 616 total,   1 running, 615 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.2 us,  0.5 sy,  0.0 ni, 97.8 id,  0.1 wa,  0.2 hi,  0.2 si,  0.0 st
MiB Mem :   7762.7 total,   4451.2 free,   1401.9 used,   1909.7 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   6092.3 avail Mem
 
    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   2576 root      20   0   10.7g  71656  27404 S   0.7   0.9   0:56.84 etcd
    346 root       0 -20       0      0      0 I   0.3   0.0   0:03.95 kworker/2:1H-kblockd
   1194 root      20   0 2398640  79308  36172 S   0.3   1.0   0:25.67 containerd
   1195 root      20   0 2398640  79308  36172 S   0.3   1.0   0:28.91 containerd
   1479 root      20   0 1788724 117000  66188 S   0.3   1.5   1:45.26 kubelet
   2077 root      20   0 1788724 117000  66188 S   0.3   1.5   1:20.84 kubelet
   2091 root      20   0 1788724 117000  66188 S   0.3   1.5   1:44.28 kubelet
   2092 root      20   0 1788724 117000  66188 S   0.3   1.5   0:26.77 kubelet

 

# 'V' : Tree 구조 View 변경

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1 root      20    238712  11408   8268 S   0.0   0.1   0:02.66 systemd
 848 root      20   0   89644  11180   9976 S   0.0   0.1   0:00.27  `- systemd-journal
 881 root      20   0   98424   9472   6820 S   0.0   0.1   0:00.31  `- systemd-udevd
1013 rpc       20   0   67240   5792   4940 S   0.0   0.1   0:00.05  `- rpcbind
1015 root      16  -4  130892   2632   1888 S   0.0   0.0   0:00.16  `- auditd
1017 root      16  -4   51776   6552   3064 S   0.0   0.1   0:00.08      `- sedispatch

 

# 'c' : 명령어 라인을 출력

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   1 root      20    238712  11408   8268 S   0.0   0.1   0:02.66 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
 848 root      20   0   89644  11180   9976 S   0.0   0.1   0:00.27  `- /usr/lib/systemd/systemd-journald
 881 root      20   0   98424   9472   6820 S   0.0   0.1   0:00.31  `- /usr/lib/systemd/systemd-udevd
1013 rpc       20   0   67240   5792   4940 S   0.0   0.1   0:00.05  `- /usr/bin/rpcbind -w -f
1015 root      16  -4  130892   2632   1888 S   0.0   0.0   0:00.16  `- /sbin/auditd
1017 root      16  -4   51776   6552   3064 S   0.0   0.1   0:00.08      `- /usr/sbin/sedispatch

 

# 필터링 조건 예시

COMMAND=wireshark  : COMMAND 필드에 "wireshark" 문자열이 포함된 프로세스만 필터링해서 출력
!USER=root         : USER 필드에 "root" 문자열이 미포함된 프로세스만 필터링해서 출력
%MEM>10.0          : MEM 사용률이 10 % 이상인 프로세스만 필터링해서 출력

 

# 화면 업데이트는 스페이스바로 가능

'Linux' 카테고리의 다른 글

How to configure syslog server  (0) 2022.12.29
How to create local YUM Repository  (0) 2022.10.12