Linux 運行進程即時監控pidstat命令詳解

來源:互聯網
上載者:User
簡介

 pidstat主要用於監控全部或指定進程佔用系統資源的情況,如CPU,記憶體、裝置IO、任務切換、線程等。pidstat首次運行時顯示自系統啟動開始的各項統計資訊,之後運行pidstat將顯示自上次運行該命令以後的統計資訊。使用者可以通過指定統計的次數和時間來獲得所需的統計資訊。

 

執行個體講解

預設參數

執行pidstat,將輸出系統啟動後所有活動進程的cpu統計資訊:

 

linux:~ # pidstatLinux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_11:37:19          PID    %usr %system  %guest    %CPU   CPU  Command……11:37:19        11452    0.00    0.00    0.00    0.00     2  bash11:37:19        11509    0.00    0.00    0.00    0.00     3  dd

指定採樣周期和採樣次數

pidstat命令指定採樣周期和採樣次數,命令形式為”pidstat [option] interval [count]”,以下pidstat輸出以2秒為採樣周期,輸出10次cpu使用統計資訊:

pidstat 2 10

 

 

cpu使用方式統計(-u)

使用-u選項,pidstat將顯示各活動進程的cpu使用統計,執行”pidstat -u”與單獨執行”pidstat”的效果一樣。

 

記憶體使用量情況統計(-r)

使用-r選項,pidstat將顯示各活動進程的記憶體使用量統計:

linux:~ # pidstat -r -p 13084 1Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_15:08:18          PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command15:08:19        13084 133835.00      0.00 15720284 15716896  96.26  mmmm15:08:20        13084  35807.00      0.00 15863504 15849756  97.07  mmmm15:08:21        13084  19273.87      0.00 15949040 15792944  96.72  mmmm

以上各列輸出的含義如下:

minflt/s: 每秒次缺頁錯誤次數(minor page faults),次缺頁錯誤次數意即虛擬記憶體地址映射成實體記憶體地址產生的page fault次數majflt/s: 每秒主缺頁錯誤次數(major page faults),當虛擬記憶體地址映射成實體記憶體地址時,相應的page在swap中,這樣的page fault為major page fault,一般在記憶體使用量緊張時產生VSZ:      該進程使用的虛擬記憶體(以kB為單位)RSS:      該進程使用的實體記憶體(以kB為單位)%MEM:     該進程使用記憶體的百分比Command:  拉起進程對應的命令

 

IO情況統計(-d)


使用-d選項,我們可以查看進程IO的統計資訊:

linux:~ # pidstat -d 1 2Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_17:11:36          PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command17:11:37        14579 124988.24      0.00      0.00  dd17:11:37          PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command17:11:38        14579 105441.58      0.00      0.00  dd

輸出資訊含義

kB_rd/s: 每秒進程從磁碟讀取的資料量(以kB為單位)kB_wr/s: 每秒進程向磁碟寫的資料量(以kB為單位)Command: 拉起進程對應的命令

 

針對特定進程統計(-p)

使用-p選項,我們可以查看特定進程的系統資源使用方式:

linux:~ # pidstat -r -p 1 1Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_18:26:17          PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command18:26:18            1      0.00      0.00   10380    640   0.00  init18:26:19            1      0.00      0.00   10380    640   0.00  init……

 

pidstat常用命令

使用pidstat進行問題定位時,以下命令常被用到:

pidstat -u 1pidstat -r 1pidstat -d 1

以上命令以1秒為資訊採集周期,分別擷取cpu、記憶體和磁碟IO的統計資訊。

 

轉自 http://www.cnblogs.com/bangerlee/articles/2555307.html

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.