1. 程式人生 > >Centos6下通過pidstat檢視各程序資源(CPU、Memory、Disk)佔用情況

Centos6下通過pidstat檢視各程序資源(CPU、Memory、Disk)佔用情況

環境說明

Centos6.8 x86_64

使用說明

很多時候我們需要檢視各進行對於硬體資源的佔用情況,譬如說CPU、Memory、Disk,在Centos6下可以通過pidstat可以檢視進行對各資源的佔用情況。
[[email protected] ~]# pidstat --help
Usage: pidstat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -C <command> ] [ -d ] [ -h ] [ -I ] [ -l ] [ -r ] [ -t ] [ -u ] [ -V ] [ -w ]
[ -p { <pid> [,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ]

      pidstat後面可以跟很多引數,但是最常用的分別是:  -u:監控cpu  -r:監控記憶體  -d:監控硬碟     我們先來通過pidstat檢視各進行佔用cpu資源情況,後面的引數“1”,為顯示列表的時間間隔,為1秒。
[[email protected] ~]# pidstat -u 1
Linux 2.6.32-642.4.2.el6.x86_64 (ovirt-host-2)  10/13/2016      _x86_64_        (8 CPU)

11:04:20 AM       PID    %usr %system  %guest    %CPU   CPU  Command
11:04:21 AM      3428    5.77    0.96    0.00    6.73     3  vdsm
11:04:21 AM      4637   13.46   10.58    0.00   24.04     1  sshd
11:04:21 AM      4639    1.92    3.85    0.00    5.77     3  virt-p2v-server
11:04:21 AM      4864    1.92    1.92    0.00    3.85     2  pidstat
11:04:21 AM     12080    0.96    2.88    0.00    3.85     2  pidstat

11:04:21 AM       PID    %usr %system  %guest    %CPU   CPU  Command
11:04:22 AM      4637   15.00    9.00    0.00   24.00     1  sshd
11:04:22 AM      4639    3.00    3.00    0.00    6.00     3  virt-p2v-server
11:04:22 AM      4864    0.00    2.00    0.00    2.00     2  pidstat
11:04:22 AM     12080    2.00    2.00    0.00    4.00     6  pidstat

11:04:22 AM       PID    %usr %system  %guest    %CPU   CPU  Command
11:04:23 AM       125    0.00    1.00    0.00    1.00     2  kswapd0
11:04:23 AM      2863    1.00    1.00    0.00    2.00     2  libvirtd
11:04:23 AM      3428    1.00    0.00    0.00    1.00     3  vdsm
11:04:23 AM      4637   14.00   10.00    0.00   24.00     1  sshd
11:04:23 AM      4639    2.00    4.00    0.00    6.00     3  virt-p2v-server
11:04:23 AM      4864    2.00    2.00    0.00    4.00     4  pidstat
11:04:23 AM     12080    1.00    2.00    0.00    3.00     2  pidstat

可以通過man pidstat中-u的內容,來了解上述列表中各引數的含義
   -u     Report CPU utilization.

              When reporting statistics for individual tasks, the following values are displayed:

              PID
                     The identification number of the task being monitored.

              %usr
                     Percentage of CPU used by the task while executing at the user level (application), with or without nice priority. Note that this field does NOT include time spent running a virtual processor.

              %system
                     Percentage of CPU used by the task while executing at the system level (kernel).

              %guest
                     Percentage of CPU spent by the task in virtual machine (running a virtual processor).

              %CPU
                     Total percentage of CPU time used by the task. In an SMP environment, the task鈙 CPU usage will be divided by the total number of CPU鈙 if option -I has been entered on the command line.

              CPU
                     Processor number to which the task is attached.

              Command
                     The command name of the task.
瞭解檢視cpu後,我們再來看看檢視記憶體
Linux 2.6.32-642.4.2.el6.x86_64 (ovirt-host-2)  10/13/2016      _x86_64_        (8 CPU)

11:07:57 AM       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
11:07:58 AM      3428     12.62      0.00 2030068  42408   0.26  vdsm
11:07:58 AM      4864    619.42      0.00  101380   1216   0.01  pidstat
11:07:58 AM     12143    621.36      0.00  101384   1192   0.01  pidstat

11:07:58 AM       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
11:07:59 AM      1860      9.00      0.00   18372    800   0.00  irqbalance
11:07:59 AM      2863      2.00      0.00  933520  10356   0.06  libvirtd
11:07:59 AM      3428     76.00      0.00 2030068  42408   0.26  vdsm
11:07:59 AM      4864    638.00      0.00  101380   1216   0.01  pidstat
11:07:59 AM     12143    646.00      0.00  101384   1224   0.01  pidstat

一樣,通過man pidstat來檢視各引數的含義
       -r     Report page faults and memory utilization.

              When reporting statistics for individual tasks, the following values are displayed:

              PID
                     The identification number of the task being monitored.

              minflt/s
                     Total number of minor faults the task has made per second, those which have not required loading a memory page from disk.

              majflt/s
                     Total number of major faults the task has made per second, those which have required loading a memory page from disk.

              VSZ
                     Virtual Size: The virtual memory usage of entire task in kilobytes.

              RSS
                     Resident Set Size: The non-swapped physical memory used by the task in kilobytes.

              Command
                     The command name of the task.

下面我們來檢視監控disk
[[email protected] ~]# pidstat -d 1
Linux 2.6.32-642.4.2.el6.x86_64 (ovirt-host-2)  10/13/2016      _x86_64_        (8 CPU)

11:12:29 AM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
11:12:31 AM      4639      0.00  11592.45      0.00  virt-p2v-server

11:12:31 AM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
11:12:32 AM      4639      0.00   8192.00      0.00  virt-p2v-server

11:12:32 AM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
11:12:33 AM      4639      0.00  12288.00      0.00  virt-p2v-server

11:12:33 AM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
11:12:34 AM      4639      0.00  12288.00      0.00  virt-p2v-server

11:12:34 AM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
11:12:35 AM      4639      0.00  12288.00      0.00  virt-p2v-server

檢視各引數的含義
    -d     Report I/O statistics (kernels 2.6.20 and later only).  The following values are displayed:

              PID
                     The identification number of the task being monitored.

              kB_rd/s
                     Number of kilobytes the task has caused to be read from disk per second.

              kB_wr/s
                     Number of kilobytes the task has caused, or shall cause to be written to disk per second.

              kB_ccwr/s
                     Number of kilobytes whose writing to disk has been cancelled by the task. This may occur when the task truncates some dirty pagecache. In this case, some IO which another task has been accounted for will not be  happening.

              Command
                     The command name of the task.



相關推薦

Centos6通過pidstat檢視程序資源CPUMemoryDisk佔用情況

環境說明 Centos6.8 x86_64 使用說明 很多時候我們需要檢視各進行對於硬體資源的佔用情況,譬如說CPU、Memory、Disk,在Centos6下可以通過pidstat可以檢視進行對各資

Windows通過CMD命令行程序操作MySQL數據庫

空格 自己 In 設置 例如 進行 mysql數據庫 ron 命令行 註意:如果您的MySQL沒有安裝在C盤下,先使用命令進入MySQL的安裝目錄下的bin目錄中才可以進行後續操作。 方法如下:例如您安裝在D盤。先輸入 D: 回車即可進入D盤,再輸入cd D:\您mysq

CentOS6通過OwnCloud搭建個人雲盤

OwnCloud簡介 OwnCloud是一個開源的個人雲儲存方案,我們利用這一套解決方案可以在自己的伺服器上搭建屬於自己的雲盤系統。 OwnCloud具有配套的網站客戶端,PC客戶端以及手機客戶端可以讓使用者方便的管理雲盤檔案 環境 1.伺服器CentO

linux-top檢視程序cpu用量等

Linux檢視程序top 命令顯示了當前正執行的程序以及關於它們的重要資訊,包括它們的記憶體和 CPU 用量。 該列表既是真實時間的也是互動的。 要退出 top,按 [q] 鍵。 如: [email protected]:/work/MT7601u官方

通過新浪雲部署NideShop微信小程序商城基於Node.js+MySQL+ThinkJS

小程序 微信 mysql 一、購買新浪雲SAE為什麽選擇SAE? 免費二級域名和支持https訪問,不用備案,可用於做微信小程序服務器。SAE推薦鏈接:http://sae.sina.com.cn/選擇對應的部署環境自定義 -> 開發言語:自定義 -> 運行環境:雲容器 -> 語

通過新浪雲部署Node.js微信小程序商城不用買域名不用備案不用配置https

個數 bre rem faq 開發 mem nbsp edi home 本文檔為微信小程序商城NideShop項目的安裝部署教程(GitHub),歡迎star 一、購買新浪雲SAE 為什麽選擇SAE?免費二級域名和支持https訪問,不用備案,可用做微信小程序服務器。 S

檢視iis程序(w3wp)所對應的程式池名稱 / 埠使用情況

有些時候,伺服器上某個iis站點程序佔用較多資源,且多個站點用相同的賬戶執行時,無法區分具體是哪個站點佔用了資源, 這時我們需要根據pid來區分,如下步驟。 1、首先在工作管理員中,勾選顯示PID列。 2、開啟CMD,輸入c:\windows\system32\inet

Linux通過logrotate定時清理壓縮軟體日誌,如mysqlnginxtomcat

tomcat日誌如果放任不管,那麼日誌檔案會越來越大,檢視起來也不方便。另外,如果catalina.out的大小超過了2G,那麼tomcat可能在沒有錯誤提示的情況下崩潰、無法啟動。 所以為了避免出現這個問題,我們應該每天分割catalina.out,logrotate就

ubuntu通過u盤安裝軟體方法命令列

    如果在我們Ubuntu沒有網路連線的情況下,安裝軟體就不可使用 apt-get install xxx,因為不能通過網路下載資料包,我們這裡介紹通過U盤用命令列的方式給Ubuntu系統安裝軟體的方法。     在將我們想要安裝的軟體包放到U盤中後(以.tar.gz檔

Windows通過VMware虛擬機器安裝UbuntuLinux及常見問題解決

Windows下通過VMware虛擬機器安裝Ubuntu(Linux) 1.安裝VMware虛擬機器 2.下載Ubuntu 3.安裝Ubuntu 3.1建立新的虛擬機器 3.2自定義安裝,下一步 3.3相容性,

第六章 面向對象的程序設計 2 創建對象

屬性設置 真的 兩個 實例方法 應用 最大 訪問 技術分享 全局 6.2 創建對象 6.2.1 工廠模式 工廠模式是軟件工程領域一種廣為人知的設計模式,這種模式抽象了創建具體對象的過程。考慮到在ECMAScript 中無法創建類,開發人員就發明了一種函數,用函數來封裝以特定

Android 雙擊退出程序實現有側滑界面

是的 tro raw idt style tap sys .com ges 大家好,今天帶來雙擊退出程序實現方法,我知道,網上也是有許多關於雙擊退出程序實現的方法,所以,聽見當然是給大家帶來不一樣的雙擊退出的實現方法。 首先帶來的便是關於onKeyDown和onKe

vue打包後出現靜態資源|圖片,json數據找不到路徑

CP 解決 png 路徑 分享圖片 分享 com 奇跡 public 最近在學習Vue是如何編寫項目的,在踩了許多坑後,終於要到了最後一步npm run build了,很開心的等待奇跡,然後打包後出現了找不到圖片路徑的問題。 解決辦法:1.將圖片或者json數據文件夾放到s

快速定位性能瓶頸,檢查出所有資源CPU內存磁盤IO等的利用率utilization飽和度saturation和錯誤error度量,即USE方法

sta lin system 1.8 磁盤 AI during run 5.7 通過分析mpstat的iowait和iostat的util%,判斷IO瓶頸 IO瓶頸往往是我們可能會忽略的地方(我們常會看top、free、netstat等等,但經常會忽略IO的負載情況),

stm32f103各個型號芯片之間程序移植stm32的兼容問題

型號 開發板 技術分享 文件中 http 工程 bsp bubuko 理論 1.stm32f103系列的各個型號的芯片差別一般不大,都是一些flash大小不一樣,一般是向下兼容(大容量芯片兼容中容量芯片)還有晶振大小不一樣。

CentOS 7.2 nginx SSL證書部署的方法使用crt以及key 配置

轉自:https://www.jb51.net/article/107350.htm   環境 系統環境:CentOS6.7 nginx version: nginx/1.8.1 證書 ?

windowsLibevent的多執行緒封裝以檔案傳輸為例

1、主執行緒負責監聽,子執行緒負責響應連線,同時每個子執行緒增加了連結串列來管理連線進來的客戶端,將上一節中的記憶體管理類也封裝進去。總體框架是不變的。 2、封裝類的實現: #pragma once #include "winsock2.h" #include "event2/liste

寫代碼如何合理使用和優化我們的機器資源CPU內存網絡磁盤

rontab ava 直接 由於 內存 說我 很多 遇到 工作 寫代碼腦子一定要繃緊一根弦,認知到我們所在的機器資源是有限的。機器資源有哪些?CPU、內存、網絡、磁盤等,如果不做好保護控制工作,一旦某一資源滿負荷,很容易導致出現線上問題。1 CPU 資源怎麽限制* 計

Centos6.8系統環境變數和別名設定永久生效和臨時生效export

1.Linux的變數種類   按變數的生存週期來劃分,Linux變數可分為兩類:  1.1 永久的:需要修改配置檔案,變數永久生效。  1.2 臨時的:使用export命令宣告即可,變數在關閉shell時失效。 2.設定變數的三種方法  2.1 在/etc/prof

強烈推薦的TensorFlowPytorch和Keras的樣例資源深度學習初學者必須收藏

本文轉自微信公眾號:機器學習初學者 原創: 機器學習初學者 機器學習初學者  TensorFlow、Keras和Pytorch是目前深度學習的主要框架,也是入門深度學習必須掌握的三大框架,但是官方文件相對內容較多,初學者往往無從下手。本人從github