0
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?

仮想ホストから、仮想ゲストのメモリ上昇率を調査する。

Posted at

概要

仮想ホスト上で仮想ゲストを構築・運用するにあたり、仮想ホストのメモリが上昇していたりするパターンがある。
その際に、どの仮想ゲストがどれくらいの使用率を利用しているかを確認するための方法を記載していく。

psコマンドの活用

psコマンドを参考にして、仮想ホスト内の使用率を確認していく。

ps -eo pid,ppid,user,%cpu,%mem,vsz,rss,stat,lstart,etime,time,args --sort=-%mem | head -n 10 | column -t

Linuxシステム上で実行中のプロセスを、メモリ使用量の多い順に上位10件表示する。

引数の内容はざっくり以下のような形である。

フィールド 意味
pid プロセスID
ppid 親プロセスID
user 実行ユーザー
%cpu CPU使用率
%mem メモリ使用率
vsz 仮想メモリサイズ(KB)
rss 常駐セットサイズ(実メモリ使用量, KB)
stat プロセス状態(例:R=実行中、S=スリープなど)
lstart プロセスの起動日時(5フィールド分ある)
etime 経過時間(起動からの時間)
time 累積CPU時間
args 実行コマンド

仮想ゲストのプロセスを検索

仮想ゲスト名がわかるのであれば、以下のコマンドで仮想ホストのプロセス名がわかる。

 ps aux --sort=-%mem | head

実行結果。これの中に、guest=~~という部分に配当するのが、ゲスト名である。ここではvm0176である。

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
qemu 111951 30.1 46.1 72241516 67106320 ? Sl 2023 279169:39 /usr/libexec/qemu-kvm -name guest=vm0176,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-19-vm0176/master-key.aes -machine pc-i440fx-rhel7.6.0,accel=kvm,usb=off,dump-guest-core=off -cpu Cascadelake-Server,ss=on,vmx=on,hypervisor=on,tsc-adjust=on,umip=on,pku=on,md-clear=on,stibp=on,arch-capabilities=on,xsaves=on,ibpb=on,rdctl-no=on,ibrs-all=on,skip-l1dfl-vmentry=on,mds-no=on,tsx-ctrl=on -m 65536 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid 3046bc94-312e-4481-9172-639d466c6c1d -display none -no-user-config -nodefaults -chardev socket,id=charmonitor,fd=37,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=delay -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x2.0x7 -device ich9-usb-中略。

こいつのPIDは111951で、メモリ使用率は46.1%になっている。

仮想ゲストの詳細を確認する場合は、以下のコマンドでゲストを調査する事ができる。

 sudo virsh dominfo ゲスト名

恒久対策

ゲスト等を、Zabbix等でどのプロセスのメモリ使用率が右肩上がりになっているのかを可視化して見れるようになると発見が容易になる。しかし、それは標準のテンプレートでは実装ができないので、zabbix_senderなどを利用してカスタムする必要があると思われる。

自分が担当していた機器のメモリ使用率の場合では、zabbixのバグによりメモリ使用率に影響が出るようであった。

0
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
0
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?