About

It is surprisingly easy to check virsh qemu-kvm processes using monit. It suffices to supply the PID file and to stop and restart the virtual machine using virsh.

Code

File: http://svn.grimore.org/configuration-templates/monit/debian/templates/libvirt-domain -

###########################################################################
##  Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3      ##
###########################################################################
 
# It is surprisingly easy to check virsh qemu-kvm processes using monit.
# It suffices to supply the PID file and to stop and restart the virtual
# machine using virsh.
 
check process libvirt-example.domain with pidfile /var/run/libvirt/qemu/example.domain.pid
    start program  "/usr/bin/virsh start example.domain"
    stop program  "/usr/bin/virsh stop example.domain"
 
check host libvirt-net-example.domain with address example.domain
    start program  "/usr/bin/virsh start example.domain"
    stop program  "/usr/bin/virsh stop example.domain"
    if failed icmp type echo count 5 with timeout 15 seconds then restart