Got a Hyper-V cluster that needs monitoring. Problem is that when a guest is moved to another host, it shows as failed on one node, and does not show up on the other node before next autodiscover


Article Comments

vMotion on HyperV is not yet sported by the sensors, sorry.


Jan, 2011 - Permalink

Any plans for this in the future?


Jan, 2011 - Permalink

We have it on our wishlist, but no target date has been set yet.


Jan, 2011 - Permalink

This would be a huge benefit to our company if this worked properly with failover clustering...

I understand no target date has been set, however, is there anyway we can get any more details on what are the chances of this being implemented in the next 3 - 6 Months?


Jan, 2011 - Permalink

Not very likely, but I also can't say this with certainty. Sorry.


Jan, 2011 - Permalink

Just to keep the interest going... I''m running into the same "problem".

Any news on a target date?


Apr, 2011 - Permalink

Count me as another with this issue.


Apr, 2011 - Permalink

PRTG now supports monitoring of Virtual Machines which were moved by Live Migration. Use the Hyper-V Virtual Machine Sensor with the System Center Virtual Machine Manager (SCVMM) as parent device and the monitoring will continue after the VM changed the physical host.

Do also have a look at our manual for further information.


Aug, 2014 - Permalink

And if you have two hyper-v servers in a cluster without SCVMM? I would say that is the most common situation in smaller companies.


Mar, 2015 - Permalink

I am afraid that this is not possible at the moment, sorry.


Mar, 2015 - Permalink

I'm running into a similar situation. We have a 3 node hyper-v cluster with on SCVMM. I just live migrated a guest server and the sensors seemed to work. However, when I look into the CPU usage... the numbers seemed to be off, like it is reporting from another server. How do I properly monitor guest VMs without SCVMM?


Feb, 2016 - Permalink

I also have Hyper-V cluster without SCVMM and we are not planning to implement it. I am wondering if anyone had implement creative hack to follow health and availability.

I guess we could have a sensor that claim everything's fine if one of two other sensors is up. Can we monitor sensors in PRTG?


Mar, 2017 - Permalink

Hello Dan,

I'm sorry, there is no native sensor and there are no known custom scripts yet.

Best regards, Felix


Mar, 2017 - Permalink

Hi All, I'm hoping I have this worked out, it might not be complete but if you come up with amendments and improvements, just post them back here. Thing's you'll need

  • FailoverCluster powershell module installed on your probe(s)
  • 64bit_runner.ps1 (below) in your EXEXML folder (C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML)
  • HyperV - Query Cluster for a VM.ps1 (below) in your EXEXML folder (C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML)

64bit_runner.ps1

param (
    [string]$filename,
    [string]$hypervclustername,
    [string]$VMName
)

if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
    &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\$filename" -hypervclustername $hypervclustername -vmname $VMName
}


HyperV - Query Cluster for a VM.ps1

param (
    [string]$hypervclustername,
    [string]$VMName
)
 
Function WriteXmlToScreen ([xml]$xml) {
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
}
 
# Make the script dynamic by getting the node list from the cluster
$clusternodes = Get-ClusterNode -Cluster $hypervclustername | select name
 
#add the list of VMs to an array
$details = @()
foreach($clusternode in $clusternodes) {
    $details += Get-VM -ComputerName $clusternode.name | select VMName, State, ComputerName, Uptime, CPUUsage, MemoryAssigned, MemoryDemand
}
 
#filter the array for the VM we asked for
$details = $details | ?{$_.VMName -eq $VMName}
 
#create the XML
$XML = "<prtg>"
foreach($detail in $details) {
    $VMName = $detail.VMName
    $VMState = $detail.State
    if($detail.state -eq "Running") {
        $CPUUsage = $detail.CPUUsage
        $cluster = $detail.ComputerName
        $MemoryUsage = ("{0:p0}" -f ($detail.MemoryDemand / $detail.MemoryAssigned)).Replace("%","")
    
        $XML += "<result>"
        $XML += "<channel>CPU Usage</channel>"
        $XML += "<value>$CPUUsage</value>"
        $XML += "<unit>CPU</unit>"
        $XML += "</result>"
 
        $XML += "<result>"
        $XML += "<channel>Memory Usage</channel>"
        $XML += "<value>$MemoryUsage</value>"
        $XML += "<unit>Percent</unit>"
        $XML += "</result>"
        $XML += "<text>Node: $cluster</text>"
    }elseif($VMState -eq "Off") {
        $XML += "<error>1</error>"
        $XML += "<text>VM Offline</text>"
    }
}
$XML += "</prtg>"
 
#output the XML
WriteXmlToScreen $XML

Process

  • First, add a new device with the name of the cluster.
  • Add a new sensor of type "EXE/Script Advanced"
  • Name the new sensor to the name of VM you want to monitor
  • Choose 64bit runner as the script
  • Enter the parameters
-filename "HyperV - Query Cluster for a VM.ps1" -hypervclustername %device -vmname %name

It's possible to add more channels, if you're not comfortable doing it, let me know i should be able to knock something together. Once we've got something workable, i can submit to script world.


Oct, 2020 - Permalink

That is superb, thanks Chris!


Oct, 2020 - Permalink

Hi, it looks like it has been truncated, the full script for the hyperV query is https://pastebin.com/TWJKaiQf Could it be updated? My edits don't seem to stick Thanks


Oct, 2020 - Permalink

Done :)


Oct, 2020 - Permalink

When I try to add the hyper-v virtual machine sensor to my SCVMM parent in PRTG, I get the following error:

Sorry, the scan for available monitoring items has failed! Could not create the Hyper-V Virtual Machine sensor on device <SCVMM Server> (<IP Address>). 80041010: The specified class is not valid.

How can I add this sensor to my SCVMM server to monitor my VMs per the PRTG recommended way?

I tried the scripts above with the 64bit runner and those seem to work well, but just curious what the difference was vs the official PRTG SCVMM method.


Jul, 2021 - Permalink

Please use this instead - https://helpdesk.paessler.com/en/support/solutions/articles/76000064836 - it has proven to be working for many customers :)


Jul, 2021 - Permalink