PR

[Linux] マルチコア CPU の使用率を確認する

個々のCPU の使用率をチェックするLinux コマンドを調べた。

チェック環境


$ uname -a
Linux vm130 2.6.35-25-server #44-Ubuntu SMP Fri Jan 21 19:09:14 UTC 2011 x86_64 GNU/Linux

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Xeon(TM) CPU 3.20GHz
stepping        : 1
cpu MHz         : 2800.331
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall lm constant_tsc pebs bts pni dtes64 monitor ds_cpl cid cx16 xtpr
bogomips        : 5600.66
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:


※物理的に2つ(デュアルプロセッサ構成)で、1CPU に2スレッドあるから、4CPU になる。同様の内容なので省略した。

スポンサードリンク

mpstat コマンド

インストール

参考文献によるとmpstat コマンドがあるらしい。


$ mpstat
The program 'mpstat' is currently not installed.  You can install it by typing:
sudo apt-get install sysstat


導入されていない場合はインストールする。


$ sudo aptitude install sysstat -y


使い方


Usage: mpstat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -A ] [ -I { SUM | CPU | ALL } ] [ -u ] [ -P { <cpu> [,...] | ALL } ] [ -V ]


使ってみる

CPU ごとに表示


$ mpstat -P ALL
Linux 2.6.35-25-server (vm130)  03/01/2011      _x86_64_        (4 CPU)

02:48:31 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
02:48:31 AM  all    0.39    0.00    5.03    0.47    0.00    0.01    0.00    0.00   94.09
02:48:31 AM    0    0.62    0.00    6.04    0.38    0.00    0.00    0.00    0.00   92.95
02:48:31 AM    1    0.28    0.00    3.03    0.36    0.00    0.02    0.00    0.00   96.31
02:48:31 AM    2    0.58    0.00    9.48    0.93    0.00    0.03    0.00    0.00   88.99
02:48:31 AM    3    0.11    0.00    1.73    0.22    0.00    0.00    0.00    0.00   97.94


5秒ごと3回実行

※回数制限の3を抜くと実行し続ける


$ mpstat 5 3
Linux 2.6.35-25-server (vm130)  03/01/2011      _x86_64_        (4 CPU)

02:50:39 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
02:50:44 AM  all    0.58    0.00    3.99    2.00    0.00    0.00    0.00    0.00   93.42
02:50:49 AM  all    0.24    0.00    2.57    0.15    0.00    0.00    0.00    0.00   97.05
02:50:54 AM  all    0.24    0.00    5.68    0.05    0.00    0.00    0.00    0.00   94.03
Average:     all    0.36    0.00    4.08    0.73    0.00    0.00    0.00    0.00   94.84


参考文献

コメント