#!/bin/bash

STATUS=$( virsh version )
STATUS_CODE=$?

if [ $STATUS_CODE -ne 0 ]
then
	echo "CRITICAL - Fail to get libvirt status"
	exit 2
else
	MSG=""
IFS="
"
	for line in $( echo -e "$STATUS"|grep ':' )
	do
		MSG+="$line - "
	done
	MSG=$( echo $MSG|sed 's/ - $//' )
	echo "OK - Libvirtd is running - $MSG"
	exit 0
fi
