#!/bin/sh # check_virt_dom_state - Check on various aspects of the virtual host and domains. # Written by Andreas Kasenides # # Inspired b check_virt written by Richard W.M. Jones # #---------------------------------------------------------------------- set -e HOSTNAME=$1 if [ -z "$HOSTNAME" ]; then echo "Usage: $0 virt-domain" exit 3 ;# Status 3 = UNKNOWN (orange) fi status=$(sudo /usr/bin/virsh domstate "$HOSTNAME" | head -1) /usr/bin/printf $HOSTNAME:$status case "$status" in running|blocked) exit 0 ;# Status 0 = OK (green) ;; paused) exit 1 ;# Status 1 = WARNING (yellow) ;; shutdown|shut\ off|crashed) exit 2 ;# Status 2 = CRITICAL (red) ;; *) exit 2 ;# Status 2 = CRITICAL (red) esac