What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Hyper-V Replication Module

Votes:

0

I'm attempting to create a sensor to report critical replication health of a VM from a probe device. I found another user who posted what seemed to be a fantastic solution, I'll include it below, however upon activating the sensor I get flagged by unexpected XML errors. I'm new to PRTG, so I'm doing my best to understand what's happening, but just don't get it. Any help would be appreciated.

# param([string]$Hypervserver)
$Hypervserver = "HyperVHost"
# $Session = New-PSSession -computername $Hypervserver 

$VMReplication = Get-VMReplication | select name,health,state

$ErrMessage = " "
$Errors = 0
$Warning = 0
$Critical = 0
foreach ($Name in $VMReplication) {
    if ($Name.Health -like "Normal" -and $Name.State -like "Replicating") {
    $state = 0
    }
    elseif ($Name.Health -like "Warning") {
    $state = 1
    $Warning = $Warning + 1
    }
    elseif ($Name.Health -like "Critical") {
    $state = 1
    $Critical = $Critical + 1
    }


$VM = $Name.Name
$Health = $NAme.Health
$Status = $Name.State
$ErrMessage = $ErrMessage, $VM, " " , $Health , " ", $Status, "`t"
 $Errors = $Errors + 1
}

If ($Errors = 0 ){
Write-Host 0 , ":OK", "Replicating is working fine"
}
elseif ($Critical = 1) {
Write-Host 10 , ":", $ErrMessage 
}
elseif ($Warning = 1) {
Write-Host 5 , ":", $ErrMessage 
}
else {
Write-Host 2 , ":", $ErrMessage
}

#Added by mod
Remove-PSSession -ID $Session.ID
#Added by mod

Exit 0

custom-sensor hyper-v replication-health

Created on Nov 4, 2019 6:09:51 PM



Replies

Nobody has replied yet


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.