Reporting on vSphere Replication transfer sizes

vSphere Replication is really a wonderful product – I’ve been using it for a few years now across a few employers and I’ve never had a really serious problem with it – it just seems to work.

Sure, there are a few feature requests we could make of it, for example setting a schedule of when to replicate and ignoring RPO violations outside of that, and bandwidth limiting on the traffic coming out of the appliance, but they really aren’t necessary for what it is designed for.

Something I like exists in the Flash/Flex UI, where we can find out the size of the last data replication was (“Last sync size” in the image below). However this only exists in this one place and I haven’t found that this can be reported on anywhere else. It’s good to know the rate of change for your servers for judging bandwidth (yes we should have monitoring on the lines, but this won’t break transfers down into individual servers)

This image has an empty alt attribute; its file name is image.png

Finding what to report upon

As I was asked to provide change rates for some servers I started in the usual place (your search engine of choice) but couldn’t find a way of extracting this information. I then looked in the Events section of a VM being replicated and found that something was being logged – hurrah !

Yes I’m still using the Flash GUI. Come at me :p

Looking at a completed event I found:

We have a number of bytes transferred – we might be able to work with this. Time to switch to PowerCLI And these are the last two events to be logged with the VM:

If we have a look at the Arguments field we find (I’ve assigned $e to the first event in the above image because laziness !):

This information should give us enough to generate a report:

  • Filter on “EventTypeId” and matching to “hbr.primary.DeltaCompletedEvent”.
  • Using the Arguments.Value field to report on the size of the transfer.

Let’s give this a try:

Get-VM $name | get-vievent -MaxSamples ([int]::MaxValue) | ? { $_.EventTypeId -eq "hbr.primary.DeltaCompletedEvent" } | Select CreatedTime, @{L="MB Transferred";E={  [math]::Round($_.Arguments.Value/1MB, 2)}}

This will display the following – perfect !

Determining accurate numbers

Let’s remind ourselves of the UI report for the last transfer size – 40.64 MB:

This image has an empty alt attribute; its file name is image.png

So we can see that the numbers don’t quite add up – the GUI reports 40.64 MB and the event reports 40.78 MB.

Time to venture onto the Internet and see if we can find out how to get from 42761392 bytes to 40.64 MB (as I’m going to assume that the VMware engineers are clever than I and I’ve made a mistake somewhere). Using Google’s inbuilt calculator we find that 42761392 bytes are 42.76 MB.

If we use we get a bit more distinction – it is 42.76 MB if we take 1 MB to mean 1000000 (decimal, megabytes), and it is 40.78 MB if 1 MB is equal to 1048576 bytes (binary, mebibytes):

So I honestly have no idea how or why the UI reports the size as being 40.64 – from the above it should be either 40.78 or 42.76 depending on the value of 1 MB in bytes. So this leaves us with the following options:

  • The Arguments.Value is incorrect.
  • We are using Arguments.Value incorrectly.
  • The UI is incorrect.

For this report, we are going to accept the inaccuracy and use 1048576 as the value of 1 MB, as this will get us closer to the UI number.

Bringing it all together

Our script to generate the report is now:

Param([Parameter(Mandatory=$true)] $VMName,
      [DateTime] $Start,
      [DateTime] $Finish,
      [string] $OutputFile);

$vm = Get-VM $VMName;
if ($null -ne $vm) {
    $EventStart = $null;
    if ($null -eq $Start) {
        $EventStart = $(Get-Date).AddDays(-7);
    } else {
        Write-Host $Start.ToString();
        $EventStart = $Start;

    $EventEnd = $null;
    if ($null -eq $Finish) {
        $EventEnd = Get-Date;
    } else {
        Write-Host $Finish.ToString();
        $EventEnd = $EventEnd;

    $events = get-vievent -MaxSamples ([int]::MaxValue) -Start $EventStart -Finish $EventEnd | ? { $_.EventTypeId -eq "hbr.primary.DeltaCompletedEvent" } | Select CreatedTime, @{L="MB Transferred";E={ [math]::Round($_.Arguments.Value/1MB, 2)}}
    if ($null -ne $events) {
        if ($null -ne $OutputFile -And $OutputFile.Length -gt 0) {
            $events | Export-Csv -NoTypeInformation -Path $OutputFile;
        } else {
    } else {
        Write-Host "Could not find any replication events for the vm $VMName" -Foreground Red;

} else {
    Write-Host "Could not find a VM with the name $VMName" -Foreground Red;

From here, we can output a CSV file, import that into Excel and make some fun graphs !

As far as my limited search engine searches have returned, there is no way to find out which VMs are protected by vSphere Replication with PowerCLI. Given that there is a vRO plugin, I think that if this needs to be used if you need further information.

I’ve uploaded the script to github 🙂

As usual, please let me know if I’ve got something wrong or you found it useful !