kvm

How to monitor a KVM installation

7 Febbraio 2014 SnetAdmin Comments Off

The purpose of this article is to describe how op5 Monitor can be used with the check_libvirt plugin for agentless monitoring of resource usage on a KVM installation. At the moment the plugin can monitor:

Host Parameters:

  • Storage pool list
  • Storage pool volume usage
  • Running VM’s

VM Parameters:

  • CPU Usage
  • Memory Usage
  • Disk I/O
  • Network I/O

 

Prerequisites

  • Libvirt drivers need to be installed on both the op5 Monitor server and on the target KVM host(s).
  • The plugin support several transport protocols. In this guideline we will explain how to use the SSH and TLS features.
    • If you want use SSH, you need to setup a key-based authentication for the monitor user on the op5 monitor server and the root user on the target KVM host (libvirt is usually running as root).
    • If you want use TLS  as communication protocol then you will need to generate client and server certificates. Please follow the libvirt.org how-to for that. Be careful and follow all the steps in that how-to before you continue. Notice that the KVM host server is the server and the op5 Monitor server is the client for the TLS communication.
  • All servers can be resolved in the DNS.
  • Update op5 Monitor to get the latest plugin pack.

 

Check commands

SSH as transport protocol

If you use SSH, import the required check-commands in your configuration (‘Configure’ -> ‘Check Command Import -> check_libvirt_kvm*’). After the import you will have the following check commands:

 

Commands for guest VM’s

COMMAND NAME COMMAND LINE
check_libvirt_kvm_guest_cpu $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -N $ARG2$ -l CPU
check_libvirt_kvm_guest_disk_io $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -N $ARG2$ -l IO
check_libvirt_kvm_guest_mem $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -N $ARG2$ -l MEM
check_libvirt_kvm_guest_net_io $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -N $ARG2$ -l NET

 

Commands for the VMs

COMMAND NAME COMMAND LINE
check_xenapi_vm_cpu $USER1$/check_xenapi.pl -S $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -N $ARG3$ -l cpu -w $ARG4$ -c $ARG5$
check_xenapi_vm_io $USER1$/check_xenapi.pl -S $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -N $ARG3$ -l io
check_xenapi_vm_mem $USER1$/check_xenapi.pl -S $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -N $ARG3$ -l mem -w $ARG4$ -c $ARG5$
check_xenapi_vm_mem_ballooned $USER1$/check_xenapi.pl -S $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -N $ARG3$ -l mem -s ballooned -w $ARG4$ -c $ARG5$
check_xenapi_vm_net $USER1$/check_xenapi.pl -S $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -N $ARG3$ -l net

 

Commands for KVM host server

COMMAND NAME COMMAND LINE
check_libvirt_kvm_host_running $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -l LIST
check_libvirt_kvm_host_storage_pool $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -l POOL -s $ARG2$
check_libvirt_kvm_host_volume $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -l VOLUME -s $ARG2$/$ARG3$
check_libvirt_kvm_host_volume_all $USER1$/check_libvirt -H qemu+ssh://$ARG1$@$HOSTADDRESS$/system -l VOLUME

Note: $ARG1$ macro in the command_line refer to the user you will use to connect to the KVM host server, in these case root, the $HOSTADDRESS$ refer to the KVM host and the $ARG2$ refer to the guest VM-name.

TLS as transport protocol

If you prefer user TLS, then you can add yourself the above check command to your configuration, you need only replace qemu+ssh with qemu+tls, (‘Configure’ -> ‘Commands’ -> ‘Add new command’ -> ‘Go’).

Adding the services

Some services example following.

Add the required services as your needs, (‘Configure’ -> ‘Host: ‘ -> ‘Go’ -> ‘Services for host ‘ -> ‘Add new service’ -> ‘Go’):

Arguments are just examples, you need to adjust them to suite your environment.

Services for guest VM

SERVICE DESCRIPTION CHECK COMMAND ARGUMENTS NOTE
VM CPU Usage check_libvirt_kvm_guest_cpu root!sandbox-peer *
VM Mem Usage check_libvirt_kvm_guest_mem root!sandbox-peer *
VM Disk IO Usage check_libvirt_kvm_guest_disk_io root!sandbox-peer *
VM Net IO Usage check_libvirt_kvm_guest_net_io root!sandbox-peer *

 

Services for KVM host server

SERVICE DESCRIPTION CHECK COMMAND ARGUMENTS NOTE
KVM storage pool usage check_libvirt_kvm_host_storage_pool root!default *
KVM guest volume usage check_libvirt_kvm_host_volume root!win-sth1!default *
KVM all volume usage check_libvirt_kvm_host_volume_all root *
KVM running vm list check_libvirt_kvm_host_running root *

 

* Note: No warning or critical arguments are used in these examples. The plugin does however support thresholds.

This plugin and these check_command has been successfully tested on CentOS/RHEL v.5.5 and 6.x with KVM 2.x.

More information about libvirt can be found at: www.libvirt.org

Articoli recenti

Categorie