2019年11月24日 星期日

Linux command top

top

top 指令說明

b  Batch mode
d  指定更新時間(單位:秒)
o  指定要輸出的欄位名稱
p  指定要觀察的pid
u  指定要觀察的使用者名稱

top -b -d 2 -p 6164  //使用batch mode,觀察pid 6164的行程並每2秒更新一次
top -d 2 -u abc   //觀察使用者abc所執行的行程並每2秒更新一次
top -b -o +%MEM | head -n 17     //使用batch mode,以記憶體做為排序依據,並只列出前17行

top上半部欄位說明

第1行
08:15:01:目前時間
up 44 min:主機開機時間
1 user:目前登入系統使用者數
load average: 1.00, 1.23, 0.86:系統每1分鐘、5分鐘、15分鐘的負載情況。
      load average資料是每隔5秒鐘檢查一次活躍的進程數,然後按特定演算法計算出的數值。
      如果這個數除以邏輯CPU的數量,結果高於5的時候就表明系統在超負荷運轉了。

第2行
Tasks:  63 total,   1 running,  62 sleeping,   0 stopped,   0 zombie:
  目前系統共63個行程,1個正在執行(running),62個休眠狀態(sleeping),
  0個已停止(stopped),0個僵屍狀態(zombie)

第3行
%Cpu(s):  1.1 us,  0.3 sy,  0.0 ni,100.0 id,  0.4 wa,  0.02 hi,  0.1 si,  0.0 st:
1.1% us — user cpu time(or)%CPU time spent in user space
0.3% sy — system cpu time(or)% CPU time spent in kernel space
0.0% ni — user nice cpu time(or) % CPU time spent on low priority processes
100% id -idle cpu time(or)%CPU time spent idle
0.4% wa — io wait cpu time(or)% CPU time spent in wait (on disk)
0.1% hi — hardware irq(or)%CPU time spent servicing/handling hardware interrupts
0.0% si — hardware irq(or)%CPU time spent servicing/handling hardware interrupts
0.0% st - steal time % CPU time in involuntary wait by virtual 
       cpu while hypervisor is servicing another processor (or) % 
      CPU time stolen from a virtual machine

第4行
KiB Mem :  1741400 total,  1600560 free,    73184 used,    67656 buff/cach
記憶體使用狀態:
1741400 total:實體記憶體容量
1600560 free:剩餘的記憶體容量
73184 used:已使用的記憶體容量
67656 buff/cache:linux用作block dev寫入buffer/block dev讀取cache記憶體容量
第5行
KiB Swap:        0 total,        0 free,        0 used.  1557120 avail Mem 
swap使用狀態:
0 total:swap總容量
0 free:剩餘的swap容量
0 used:已使用swap容量
1557120 avail Mem (available)新process在不使用swap請況下啟動
              可配置多少記憶體,應是mem free + buff/cache

top下半部欄位說明

PID — 行程id(Process ID)
USER — 該行程使用者
PR — 行程優先順序
NI — nice值(值越小優先權優高)
VIRT — 該行程使用的虛擬記憶體總量,單位kb(VIRT=SWAP+RES)
RES — 該行程使用的、未被換出的實體記憶體大小,單位kb(RES=CODE+DATA)
SHR — 共用記憶體大小(單位kb)
S — 行程狀態。D=不可中斷的睡眠狀態 R=運行 S=睡眠 T=跟蹤/停止 Z=僵屍進程
%CPU — 上次更新到現在的CPU時間佔用百分比
%MEM — 行程使用的實體記憶體百分比
TIME+ — 行程使用的CPU時間總計,單位1/100秒
COMMAND — 行程名稱

e/E  時間顯示單位切換,可分s,ms,gs,ts,ps
f/F  Fields Management可自行選擇要顯示的欄位
h  叫出help說明
k  刪除指定行程
l  隱藏/顯示load average(第1行)資訊切換
L  尋找字串
M  隱藏/顯示memory info (第4行)資訊切換
P  依據cpu用量進行排序
q  離開top
R  修改nice值
S  更改延遲時間(預設3秒)
t  隱藏/顯示tasks(第2.3行)資訊切換
T  依據Time+時間/累計時間進行排序

top按鈕說明

Summary Area Commands

按鍵  說明
c show scroll coordinates toggle
l load average/uptime toggle
t task/cpu statues toggle
m  memroy/swap toggle
1  single/seprate cpu states toggle
   顯示單一/多cpu使用情形切換
2 numa node /cpu summary toggle
3 expand numa node

Task Area Commands

按鍵  說明
j
J
B  將欄位值做粗體/一般字體切換
x
y
z  顯示顏色切換
Z  更改排序方式/顏色切換時之顏色

沒有留言:

張貼留言