How to monitor Hyper-V Replica Health with Paessler PRTG

With this quick and dirty VBS Script you can Monitor Hyper-V Replica Health with Peassler PRTG.
Replace server.domain.local with IP or DNS Name of your Hyper-V Server.
The PRTG Service Account needs to have Admin rights on Hyper-V Host (SYSTEM uses AD Computer Account to access remote Servers).
Save the VBS in “C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE” Folder.
Create a Custom EXE/Script Sensor and select the Script.
You have to install the Windows Management Framework 3.0 .

set objWshShell = CreateObject("WScript.Shell")

locstrCommand = "cmd /c powershell.exe Invoke-Command -ComputerName server.domain.local -ScriptBlock { Get-VMReplication ^| where Health -ne 'Normal' ^| measure-object }"

Set locobjExec = objWshShell.Exec(locstrCommand)

Do While Not locobjExec.StdOut.AtEndOfStream
 locstrReadline = trim(locobjExec.StdOut.ReadLine())
 locstrReadline = replace(locstrReadline, " ", "")
 wscript.echo locstrReadline
 if left(lcase(locstrReadline), len("count:0")) = "count:0" then 
  wscript.echo "0:Ok"
  wscript.quit 0
 end if

wscript.echo "2:One or more Hyper-V Replicas are different from Normal!"
wscript.quit 2

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s