Hi. What sensor can be used only for monitoring total quantity and status of guest VM in Hyper-V 2012R2 claster (SCVMM)?


Article Comments

Hi,

Unfortunalty this does not work "out of the box". However here is a small proof-of-concept to show you how it could be done. You can use it in conjunction with a EXE/script sensor.

Please note that this is untested and might be incomplete, i.e. needs further refinement to work properly.

param($host)

$VirtualMachines = (Get-VM | ft Name, VMHost, HostGroupPath, Status -auto)
$Count = $VirtualMachines | Measure-Object

foreach($VM in $VirtualMachines){
	If($VM.Stats -ne "Running"){
		Write-Host "0:VM in a critical state: $VM.Name"
		exit 2
	}
}
Write-Host "$($Count):$Count virtual machines are running normally.)"

Jan, 2015 - Permalink