1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Linux mpstatコマンド を試してみる

Last updated at Posted at 2021-10-11

マルチプロセッサ統計ツールの mpstat(MultiProcessor STATistics)を試してみます。

1. 環境

さくらのクラウド(IaaS) 2CPU 2GB

$ cat /etc/redhat-release
CentOS Stream release 8

2. インストール

$ yum install sysstat

3. シンプルに動作させてみる

$ mpstat
Linux 4.18.0-257.el8.x86_64 (localhost.localdomain)     2021年10月12日  _x86_64_        (2 CPU)

00時09分34秒  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
00時09分34秒  all    0.08    0.02    0.05    0.01    0.05    0.05    0.10    0.00    0.00   99.64
項目 説明
CPU 論理CPU ID。サマリ情報ではall
%usr ユーザー時間
%nice ナイス値で優先度を操作したプロセスのユーザー時間
%sys システム時間(カーネル)
%iowait I/O待ち時間
%irq ハードウェア割り込みによるCPU使用時間
%soft ソフトウェア割り込みによるCPU使用時間
%steal ほかのテナントのために使われたCPU時間
%guest ゲスト仮想マシンのために使われたCPU時間
%idle アイドル時間

4. CPUごとの統計情報を1秒毎に出力させる

$ mpstat -P ALL 1
Linux 4.18.0-257.el8.x86_64 (localhost.localdomain)     2021年10月12日  _x86_64_        (2 CPU)

00時16分59秒  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
00時17分00秒  all    0.00    0.00    0.00    0.00    0.00    0.00    0.50    0.00    0.00   99.50
00時17分00秒    0    0.00    0.00    0.00    0.00    0.00    0.00    0.99    0.00    0.00   99.01
00時17分00秒    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

00時17分00秒  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
00時17分01秒  all    0.00    0.00    0.00    0.00    0.50    0.00    0.00    0.00    0.00   99.50
00時17分01秒    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
00時17分01秒    1    0.00    0.00    0.00    0.00    0.99    0.00    0.00    0.00    0.00   99.01

00時17分01秒  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
00時17分02秒  all    0.50    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   99.01
00時17分02秒    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
00時17分02秒    1    0.98    0.00    0.98    0.00    0.00    0.00    0.00    0.00    0.00   98.04

5. ヘルプ情報

$ mpstat -h
使い方: mpstat [ オプション ] [ <時間間隔> [ <カウント数> ] ]
Options are:
[ -A ] [ -n ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ]
[ -N { <node_list> | ALL } ] [ -o JSON ] [ -P { <cpu_list> | ALL } ]

6. 参考

詳解 システム・パフォーマンス:O'Reilly

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?