As part of running a mini-scale run in my lab, I had to frequently monitor the replication health and also note down the replication statistics. The statistics is available by by right clicking on the VM (in the Hyper-V Manager or Failover Cluster Manager) and choosing the Replication submenu and clicking on the View Replication Health… option.
Clicking on the above option, displays the replication statistics which I am looking for.
Clicking on the ‘Reset Statistics’ clears the statistics collected so far and resets the start (“From time” field) time.
In a large deployment, it’s not practical to right click on each VM to get the health statistics. Hyper-V PowerShell cmdlets help in simplifying the task. I had two requirements:
Measure-VMReplication provides the replication statistics for each of the replicating VMs. As I am only interested in the average replication size, the following cmdlet provides the required information.
Like most of the other PowerShell cmdlets Measure-VMReplication takes the computer name as an input. To get the replication stats for all the VMs in the cluster, I would need to enumerate the nodes of the cluster and pipe the output to this cmdlet. The Get-ClusterNode is used to get the nodes of the cluster.
We can pipe the output of each node of the cluster and the replication health of the VMs present on that node
Requirement #1 is met, now let’s look at requirement #2. To snap all the replicating VMs statistics to a common start time, I used the Reset-VMReplicationStatistics which takes the VMName as an input. However if Reset-VMReplicationStatistics is used on a non-replicating VM, the cmdlet errors out with the following error message:
It’s a touch messy and to address the issue, we would need to isolate the replicating VMs in a given server. This can be done by querying only for those VMs whose ReplicationMode is set (to either Primary or Replica). The output of Get-VM is shown below
Cluster22-TPCC3 is a replicating VM (Primary VM) while replication has not been enabled on IOMeterBase VM. Putting things together, to get all the replicating VMs in the cluster use the Get-VM cmdlet and filter on ReplicationMode (Primary or Replica. You could also use the not-equal to operation get both primary and replica VMs)
To reset the statistics, pipe the above cmdlet to Reset-VMReplicationStatistics
Wasn’t that a lot easier than right clicking on each VM in your cluster and clicking on the ‘Reset Statistics’ button? :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.