Resource usage collection with libvirt
The first step in monitoring virtual machines is to get familiar with the tools to collect metrics on the subsystems we would like to later alert on. In this recipe, we are going to focus on CPU, memory, and block device utilization of the KVM guests. We are also going to learn how to use the QEMU monitoring socket and the QEMU guest agent.
Libvirt exposes a set of calls that the virsh
command leverages to gather resource usage information on the specified guest/domain. We are going to monitor and alert on the information collected here in the Monitoring KVM instances with Sensu recipe later in this chapter.
Getting ready
For this recipe, we are going to need the following:
- A server with libvirt installed and configured
- A running KVM instance
How to do it...
To collect various resource usage information for a running instance or the hypervisor host, perform the following:
- Obtain information on the hypervisor CPU utilization:
root@kvm:~# virsh nodecpustats -...