Linux 系統監控命令使用執行個體講解,linux執行個體講解

來源:互聯網
上載者:User

Linux 系統監控命令使用執行個體講解,linux執行個體講解

Linux 系統監控

Top命令

Processes: 355 total, 3 running, 352 sleeping, 1540 threads            22:53:50Load Avg: 2.23, 1.85, 1.79  CPU usage: 2.91% user, 3.4% sys, 94.3% idleSharedLibs: 203M resident, 47M data, 29M linkedit.MemRegions: 67938 total, 2480M resident, 96M private, 956M shared.PhysMem: 9029M used (3177M wired), 7345M unused.VM: 995G vsize, 627M framework vsize, 66673141(0) swapins, 67456042(0) swapouts.Networks: packets: 10075546/9110M in, 7870367/1935M out.Disks: 5209393/349G read, 3216109/340G written.PID    COMMAND      %CPU TIME     #TH    #WQ  #PORT MEM    PURG   CMPRS  PGRP36055  git          0.0  00:00.06 1      0    10    928K   0B     0B     3562636054  git          0.0  00:01.33 2      0    11    7628K  0B     0B     3562636052  mdworker     0.0  00:00.06 4      1    48    5224K  0B     0B     3605236051  mdworker     0.0  00:00.03 3      1    46    2932K  0B     0B     3605136050  mdworker     0.0  00:00.06 4      1    48    8084K  0B     0B     3605036049  top          2.8  00:06.87 1/1    0    25    3400K  0B     0B     3604935964  bash         0.0  00:00.07 1      0    16    2668K  0B     0B     3596435963  login        0.0  00:00.02 2      1    29    1132K  0B     0B     3596335961  Google Chrom 0.0  00:05.98 18     2    156   77M    0B     0B     480435955  git-remote-h 0.1  00:00.29 2      1    37    10M    0B     0B     3562635954  git          0.0  00:00.02 1      0    10    6932K  0B     0B     3562635949  git-remote-h 0.1  00:00.26 2      1    37    4672K+ 0B     0B     3562635948  git          0.0  00:00.01 1      0    10    968K   0B     0B     3562635940  bash         0.0  00:00.00 1      0    8     460K   0B     0B     35626

然而還有個好用的工具那就是 glances(驚鴻一瞥)

mac下載方法:

brew install -y glances

Linux Ubuntu:

apt install -y glances

Linux Centos:

yum install -y glances

Pip:

pip install glances

glances使用方法:

在終端直接敲glances:

CPU [ 9.3%] CPU / 9.3% nice: 0.0% ctx_sw: 441 MEM - 61.2% SWAP - 52.6% LOAD 8-core

MEM [ 61.3%] user: 6.7% inter: -2515 total: 16.0G total: 2.00G 1 min: 1.69

SWAP [ 52.6%] system: 2.7% sw_int: 446 used: 9.80G used: 1.05G 5 min: 1.72

idle: 90.7% syscal: 0 free: 6.20G free: 970M 15 min: 1.73

 

NETWORK Rx/s Tx/s TASKS 195 (939 thr), 195 run, 0 slp, 0 oth sorted automatically by cpu_percent, flat view

awdl0 0b 0b

bridge0 0b 0b CPU% MEM% VIRT RES PID USER NI S TIME+ Command

en0 2Kb 864b 39.3 0.7 3.45G 121M 293 yuqibing 0 R 11:12.56 /Applications/Utilities/Terminal.

en1 0b 0b 4.9 0.9 4.21G 155M 18921 yuqibing 0 R 47:40.92 /Applications/Google Chrome.app/C

en2 0b 0b 2.9 0.1 2.44G 13.1M 4811 yuqibing 0 R 22:06.99 /System/Library/Frameworks/VideoT

lo0 280b 280b 2.7 0.3 2.41G 43.9M 38637 yuqibing 0 R 0:03.34 /Library/Frameworks/Python.framew

p2p0 0b 0b 2.4 1.2 9.44G 190M 4809 yuqibing 0 R 1h10:32 /Applications/Google Chrome.app/C

utun0 0b 0b 1.4 1.7 5.19G 276M 4804 yuqibing 0 R 2h05:54 /Applications/Google Chrome.app/C

utun1 0b 0b 1.2 0.7 2.96G 115M 370 yuqibing 0 R 7:49.55 /System/Library/Input Methods/SCI

0.5 2.3 4.04G 383M 19198 yuqibing 0 R 3:53.39 /Applications/Google Chrome.app/C

DISK I/O R/s W/s 0.3 0.6 3.63G 103M 35137 yuqibing 0 R 0:42.80 /Applications/Google Chrome.app/C

disk0 494K 0 0.1 0.2 3.55G 34.1M 18920 yuqibing 0 R 1:15.87 /Applications/Google Chrome.app/C

disk2 0 0 0.1 0.5 3.70G 83.3M 18944 yuqibing 0 R 3:57.14 /Applications/Google Chrome.app/C

disk3 0 0 0.1 0.5 3.67G 90.0M 19058 yuqibing 0 R 1:23.48 /Applications/Google Chrome.app/C

0.1 0.1 4.48G 10.1M 19543 yuqibing 0 R 0:54.79 /Library/Java/JavaVirtualMachines

FILE SYS Used Total 0.1 0.2 3.57G 25.7M 19560 yuqibing 0 R 0:52.25 /Applications/Google Chrome.app/C

/ (disk1) 115G 233G 0.1 0.6 3.39G 106M 35625 yuqibing 0 R 0:01.54 /Applications/Google Chrome.app/C

_sX-NG-R8 18.0M 22.4M 0.0 0.4 2.67G 72.3M 111 root 0 R 2:18.93 /System/Library/CoreServices/logi

_CCB6B9D7 118G 233G 0.0 0.1 2.41G 13.4M 278 yuqibing 0 R 0:54.79 /usr/sbin/cfprefsd agent

0.0 0.1 2.43G 20.3M 279 yuqibing 0 R 1:11.77 /usr/libexec/UserEventAgent (Aqua

SENSORS 0.0 0.1 2.40G 11.8M 281 yuqibing 0 R 2:58.90 /usr/sbin/distnoted agent

Battery 46% 0.0 0.2 2.45G 25.4M 283 yuqibing 0 R 0:49.88 /System/Library/Frameworks/CoreTe

0.0 0.1 2.43G 16.4M 284 yuqibing 0 R 0:12.73 /usr/libexec/lsd

0.0 0.1 3.46G 18.3M 285 yuqibing 0 R 1:55.30 /usr/libexec/trustd --agent

0.0 0.1 2.42G 13.4M 289 yuqibing 0 R 0:06.44 /System/Library/CoreServices/shar

Glances 會用一下幾種顏色來代表狀態:

綠色:OK(一切正常)藍色:CAREFUL(需要注意)紫色:WARNING(警告)紅色:CRITICAL(嚴重)

Glances 的選項:

a – 對進程自動排序c – 按 CPU 百分比對進程排序m – 按記憶體百分比對進程排序p – 按進程名字母順序對進程排序i – 按讀寫頻率(I/O)對進程排序d – 顯示/隱藏磁碟 I/O 統計資訊f – 顯示/隱藏檔案系統統計資訊n – 顯示/隱藏網路介面統計資訊s – 顯示/隱藏感應器統計資訊y – 顯示/隱藏硬碟溫度統計資訊l – 顯示/隱藏日誌(log)b – 切換網路 I/O 單位(Bytes/bits)w – 刪除警告日誌x – 刪除警告和嚴重日誌1 – 切換全域 CPU 使用方式和每個 CPU 的使用方式h – 顯示/隱藏這個協助畫面t – 以組合形式瀏覽網路 I/Ou – 以累計形式瀏覽網路 I/Oq – 退出(‘ESC‘ 和 ‘Ctrl&C‘ 也可以)

更多glances的選項,可以用

man glances來參看。
遠程使用 Glances
glances -sDefine the password for the Glances serverPassword: Password (confirm): Glances server is running on 0.0.0.0:61209

當你執行了glances -s命令後,會讓你為 Glances 伺服器設定密碼。當你設定完畢,你將看到 “Glances server is running on 0.0.0.0:61209” (Glances 伺服器正在 0.0.0.0 的 61209 連接埠運行)的訊息。當 Glances 伺服器啟動後,到本地執行下面的命令來指定伺服器IP地址或主機名稱以連結。

註:這裡的172.16.27.56是我 Glances 伺服器的 IP 位址。glances -c -P 172.16.27.56

下面是一些在使用伺服器/用戶端模式時必須知道的事情:

在伺服器模式,你可以通過-B 地址來設定綁定地址,也可以通過-p 連接埠來綁定監聽的 TCP 通訊埠在用戶端模式,你可以通過同樣的-p 連接埠來指定伺服器連接埠預設的綁定地址是 0.0.0.0,但這麼做會監聽所有網路介面的指定連接埠在伺服器/用戶端模式下,限制的閥值將由伺服器的設定決定你也可以在命令列下用過-P 密碼的方式來為伺服器端設定一個密碼

pmap

可以根據進程查看進程相關資訊佔用的記憶體情況,(進程號可以通過ps查看)如下所示:

  $ pmap -d 5647

Linux中使用free來查看記憶體

  $ free

total used free shared buffers cached

Mem: 8193564 7868388 325176 0 198848 2645932

-/+ buffers/cache: 5023608 3169956

Swap: 0 0 0

如何看額定值:

cat /proc/meminfo

proc:

/proc是Linux的一個偽檔案系統,儲存的是當前核心運行狀態的一系列特殊檔案,使用者可以通過這些檔案查看有關係統硬體及當前正在運行進程的資訊,甚至可以通過更改其中某些檔案來改變核心的運行狀態。

/proc/cpuinfo cpu的相關資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.