6
4

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 5 years have passed since last update.

KVMのhost全体で割り当てているvCPU数とメモリ量の集計

Last updated at Posted at 2017-08-27

KVMで仮想マシンのCPU、メモリ集計

ドメイン(仮想マシン)個別の値を表示する機能はあるがホスト全体での数値を知りたかったのでてきとーに集計。

やりかた

現在稼働中のドメインのみ集計する。見たいのは設定値の上限なのでそこを対象として集計。停止中のものも含める場合はvirsh list --allに置き換える。

ドメイン数の集計

# virsh list | awk 'NR>2 && $1!="" {sum += 1} END {print sum}'
14

vCPU数の集計

# virsh list | awk 'NR>2 && $1!="" {print $2}' | xargs -n 1 virsh vcpucount | \
awk 'NR%5==1 {sum += $3} END {print sum}'
50

メモリの集計

# virsh list | awk 'NR>2 && $1!="" {print $2}' | xargs -n 1 virsh dommemstat | \
awk 'NR%3==1 {sum += $2} END {print sum/1024/1024 "GB"}'
97GB

ホストの情報を見るとCPUがオーバーコミットなのが分かる。

# virsh nodeinfo
CPU モデル:       x86_64
CPU:                 32
CPU 周波数:       2199 MHz
CPU ソケット数: 1
ソケットあたりのコア数: 8
コアあたりのスレッド数: 2
NUMA セル数:      2
メモリー容量:  165205404 KiB

参考用

# virsh version
コンパイル時に使用したライブラリ: libvirt 0.10.2
使用中のライブラリ: libvirt 0.10.2
使用中の API: QEMU 0.10.2
実行中のハイパーバイザー: QEMU 0.12.1

# yum list installed | grep libvirt
libvirt.x86_64                        0.10.2-60.el6             @base
libvirt-client.x86_64                 0.10.2-60.el6             @base
libvirt-python.x86_64                 0.10.2-60.el6             @base
libvirt-snmp.x86_64                   0.0.2-5.el6               @base
6
4
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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?