티스토리 뷰

Cloud

Hypervisor KVM 모니터링하기 2

naleejang 2021. 3. 8. 23:07

안녕하세요~!! 지난 포스팅에서 KVM 이 설치된 호스트의 시스템 정보와 사용량을 알아보았다면, 이번에는 KVM 위에 생성된 VM의 자원 정보 및 사용량에 대해 어떻게 모니터링하면 되는지 알아보도록 하겠습니다. 이건 오픈스택의 컴퓨트 노드에 생성된 인스턴스를 이미 고객이 사용하고 있다고 가정했을 경우 운영자는 고객의 VM에 접속하여 시스템 정보를 확인하거나 모니터링을 할 수는 없을 것입니다. 그렇지만,  VM의 자원정보와 사용량을 모니터링하여 자원 증설 계획을 세울 경우 유용하게 활용할 수 있습니다. 물론 모니터링 시스템을 준비하는 동안에 잠시 사용하는것이 좋겠지요~!!

인스턴스(VM) 자원 정보 확인하기

이번에는 주변에 있는 리눅스 서버에 먼저 접속을 해 봅시다. 그리고, 해당 서버에 KVM이 설치되어 있고, 그 위에는 VM도 생성되어 실행이 되고 있습니다. 먼저 VM이 실행중인지 확인해 보겠습니다. 제가 접속한 리눅스에는 아래와 같이  director13이라는 이름을 가진 vm 하나가 실행중입니다.

[nalee@rhel8 ~]$ sudo virsh list
 Id   Name         State
----------------------------
 1    director13   running

먼저 VM의 사양정보를 먼저 확인해 봅시다. CPU와 Memory는 얼마나 할당이 되어 있는지 궁금하니까요~!! 지금 확인해 본 VM은 현재 실행중이며, CPU는 4 코어가 할당되었으며, 메모리는 8 GB가 할당되었음을 알 수 있습니다. 그리고, 디스크는 Persistent 볼륨을 사용하고 있다는 사실도 알 수 있습니다.

[nalee@rhel8 ~]$ sudo virsh dominfo 1
Id:             1
Name:           director13
UUID:           62c5743c-a403-4348-b54b-a4c8b040121c
OS Type:        hvm
State:          running
CPU(s):         4
CPU time:       5099.1s
Max memory:     8388608 KiB
Used memory:    8388608 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: selinux
Security DOI:   0
Security label: system_u:system_r:svirt_t:s0:c348,c446 (enforcing)

VM의 기본 정보를 알아보았으니 이번에는 해당 VM의 CPU가 호스트의 CPU 자원을 얼마나 사용하는지 Memory는 얼마나 쓰고 있는지 알아보겠습니다. 아래와 같이 virsh vcpuinfo 명령어를 이용해 VCPU가 실제 호스트의 몇번째 CPU를 사용하고 있는지를 알수 있습니다. 

[nalee@rhel8 ~]$ sudo virsh vcpuinfo 1
VCPU:           0
CPU:            3
State:          running
CPU time:       401.4s
CPU Affinity:   yyyyyyyy

VCPU:           1
CPU:            6
State:          running
CPU time:       510.2s
CPU Affinity:   yyyyyyyy

VCPU:           2
CPU:            2
State:          running
CPU time:       572.8s
CPU Affinity:   yyyyyyyy

VCPU:           3
CPU:            0
State:          running
CPU time:       594.3s
CPU Affinity:   yyyyyyyy
[nalee@rhel8 ~]$ 

virsh cpu-stats 명령어를 이용하면 아래와 같이 호스트의 어떤 CPU가 게스트의 CPU 사용을 위해 얼마나 사용이 되었는지를 확인할 수 있습니다. virsh 명령어를 이용하면 가상머신 자체 사용율 뿐만 아니라 실제 호스트의 자원 사용율을 함께 확인할 수 있어 성능이나 자원 정보를 확인할 경우 매우 도움이 많이 됩니다.

[nalee@rhel8 ~]$ sudo virsh cpu-stats 1
CPU0:
	cpu_time            65.069415867 seconds
	vcpu_time           64.803098365 seconds
CPU1:
	cpu_time            59.371172217 seconds
	vcpu_time           59.136108708 seconds
CPU2:
	cpu_time            57.366378825 seconds
	vcpu_time           57.013888348 seconds
CPU3:
	cpu_time            25.145053735 seconds
	vcpu_time           24.055350865 seconds
CPU4:
	cpu_time             9.517770960 seconds
	vcpu_time            8.360835460 seconds
CPU5:
	cpu_time            30.533177965 seconds
	vcpu_time           29.464196607 seconds
CPU6:
	cpu_time            20.948436620 seconds
	vcpu_time           19.580697413 seconds
CPU7:
	cpu_time            52.430419193 seconds
	vcpu_time           52.084173926 seconds
Total:
	cpu_time           320.383843040 seconds
	user_time            1.910000000 seconds
	system_time         14.280000000 seconds

virsh domfsinfo 명령어를 VM이 사용중인 파일 시스템 정보를 아래와 같이 확인할 수 있습니다.

[nalee@rhel8 ~]$ sudo virsh domfsinfo 1
 Mountpoint                            Name   Type   Target
-------------------------------------------------------------
 /                                     dm-0   xfs    vda
 /boot                                 vda1   xfs    vda
 /var/lib/containers/storage/overlay   dm-0   xfs    vda

virsh domblklist는 볼륨 정보를 확인할 수 있으며, VM의 OS 볼륨 위치를 확인할 수 있습니다. 

[nalee@rhel8 ~]$ sudo virsh domblklist 1 
 Target   Source
----------------------------------------------------
 vda      /var/lib/libvirt/images/director13.qcow2
 sda

또한, virsh domblkstat 명령어를 통해 볼륨 I/O 정보 또한 확인이 가능합니다. 이와 같은 경우 볼륨에 데이터를 읽고 쓸 경우 얼마나 로드가 발생하는지에 대한 Input / Output 성능 정보를 확인할 수 있습니다.

[nalee@rhel8 ~]$ sudo virsh domblkstat 1 
 rd_req 33103
 rd_bytes 955476908
 wr_req 322107
 wr_bytes 2361260032
 flush_operations 37057
 rd_total_times 7176918990
 wr_total_times 82386233228
 flush_total_times 53510892673

이번에는 VM에 할당된 네트워크 정보를 virsh domiflist 명령어를 통해 확인해 볼 수 있습니다. 지금 조회한 VM은 네트워크를 3개나 가지고 있는것을 확인할 수 있습니다. 이와 더불어   해당  네트워크의 MAC 주소까지 확인할 수 있습니다.

[nalee@rhel8 ~]$ sudo virsh domiflist 1
 Interface   Type      Source      Model    MAC
---------------------------------------------------------------
 vnet0       network   external    virtio   52:54:00:6b:97:28
 vnet1       network   provision   virtio   52:54:00:71:99:4b
 vnet2       network   mgmt        virtio   52:54:00:a5:64:bb

이렇게 조회된 네트워크는 각각 virsh domifstat 명령어를 이용해 아래와 같이 네트워크 I/O와 같은 성능 정보들을 확인할 수 있습니다.

[nalee@rhel8 ~]$ sudo virsh domifstat 1 vnet0
vnet0 rx_bytes 70888
vnet0 rx_packets 1051
vnet0 rx_errs 0
vnet0 rx_drop 0
vnet0 tx_bytes 2474
vnet0 tx_packets 28
vnet0 tx_errs 0
vnet0 tx_drop 0

[nalee@rhel8 ~]$ sudo virsh domifstat 1 vnet1
vnet1 rx_bytes 84781
vnet1 rx_packets 1289
vnet1 rx_errs 0
vnet1 rx_drop 0
vnet1 tx_bytes 17550
vnet1 tx_packets 321
vnet1 tx_errs 0
vnet1 tx_drop 0

[nalee@rhel8 ~]$ sudo virsh domifstat 1 vnet2
vnet2 rx_bytes 69111
vnet2 rx_packets 1090
vnet2 rx_errs 0
vnet2 rx_drop 0
vnet2 tx_bytes 2650
vnet2 tx_packets 49
vnet2 tx_errs 0
vnet2 tx_drop 0

물론  해당 VM의 CPU 정보부터 네트워크 디바이스의 I/O 성능 정보까지 모두 확인해 보고 싶다면 아래와 같이 virsh domstats 명령어를 이용하면  VM의 전체적인 성능 정보를 확인할 수 있습니다. 

[nalee@rhel8 ~]$ sudo virsh domstats 1
Domain: 'director13'
  state.state=1
  state.reason=1
  cpu.time=5310695690591
  cpu.user=10840000000
  cpu.system=335080000000
  cpu.cache.monitor.count=0
  balloon.current=8388608
  balloon.maximum=8388608
  balloon.swap_in=0
  balloon.swap_out=0
  balloon.major_fault=321
  balloon.minor_fault=149592
  balloon.unused=7778764
  balloon.available=7997212
  balloon.usable=7678828
  balloon.last-update=1614951779
  balloon.disk_caches=66000
  balloon.hugetlb_pgalloc=0
  balloon.hugetlb_pgfail=0
  balloon.rss=7682848
  vcpu.current=4
  vcpu.maximum=4
  vcpu.0.state=1
  vcpu.0.time=968690000000
  vcpu.0.wait=0
  vcpu.1.state=1
  vcpu.1.time=1351430000000
  vcpu.1.wait=0
  vcpu.2.state=1
  vcpu.2.time=1463220000000
  vcpu.2.wait=0
  vcpu.3.state=1
  vcpu.3.time=1492330000000
  vcpu.3.wait=0
  net.count=3
  net.0.name=vnet0
  net.0.rx.bytes=79924
  net.0.rx.pkts=1198
  net.0.rx.errs=0
  net.0.rx.drop=0
  net.0.tx.bytes=2544
  net.0.tx.pkts=29
  net.0.tx.errs=0
  net.0.tx.drop=0
  net.1.name=vnet1
  net.1.rx.bytes=92301
  net.1.rx.pkts=1411
  net.1.rx.errs=0
  net.1.rx.drop=0
  net.1.tx.bytes=19282
  net.1.tx.pkts=355
  net.1.tx.errs=0
  net.1.tx.drop=0
  net.2.name=vnet2
  net.2.rx.bytes=75159
  net.2.rx.pkts=1192
  net.2.rx.errs=0
  net.2.rx.drop=0
  net.2.tx.bytes=2776
  net.2.tx.pkts=52
  net.2.tx.errs=0
  net.2.tx.drop=0
  block.count=2
  block.0.name=vda
  block.0.path=/var/lib/libvirt/images/director13.qcow2
  block.0.backingIndex=2
  block.0.rd.reqs=33083
  block.0.rd.bytes=955476480
  block.0.rd.times=7176880319
  block.0.wr.reqs=435532
  block.0.wr.bytes=3092401152
  block.0.wr.times=110727725424
  block.0.fl.reqs=48858
  block.0.fl.times=70697308478
  block.0.allocation=98203009024
  block.0.capacity=107374182400
  block.0.physical=111672762368
  block.1.name=sda
  block.1.rd.reqs=20
  block.1.rd.bytes=428
  block.1.rd.times=38671
  block.1.wr.reqs=0
  block.1.wr.bytes=0
  block.1.wr.times=0
  block.1.fl.reqs=0
  block.1.fl.times=0

이제  VM에 접속할 수 없다고, VM 내부에 성능 측정 에이전트를 설치하지 않았더라도, virsh 명령어를 통해 간단하게 VM의 사양 및 성능 정보를 확인할 수 있습니다. 이런 정보들만 로그로 잘 수집하여 가공한다면, 더없이 훌륭한 모니터링 데이터가 되겠지요~!! 임시로 가끔 필요한 정보를 확인해 보거나, 모니터링 시스템이 갖추어지기 전이라면 충분히 명령어를 통해 확인 할 수 있습니다. 

다음 포스팅에서는  네트워크 패킷 캡처 프로그램이 없이도 리눅스 명령어를 통해 패킷 정보를 확인해 보는 방법에 대해 포스팅하고자 합니다. 그럼, 다음 포스팅에서 만나요~!!

'Cloud' 카테고리의 다른 글

클라우드 가상화 비율  (6) 2021.06.03
Hypervisor KVM 모니터링하기 3  (0) 2021.03.20
Hypervisor KVM 모니터링하기 1  (2) 2021.03.06
GlusterFS & Heketi on Rhel7 설치 3  (0) 2021.01.13
GlusterFS & Heketi on Rhel7 설치 2  (0) 2021.01.13
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함