Page 1 of 1

VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 7:58 am
by denkteich
Hi all,

I'm new to VSAN Free. I've setup a 2 node cluster using CreateHA(two nodes).ps1.
Got it working and connected to my vmware.

How can I check the sync state with powershell?

Tried to use parts of the script without any luck.
The $device object is created via Add-HDADevice, which is not working on an already created HADevice.
Get-Device with the IP of the first node fails with:
The property 'Connected' cannot be found on this object. Verify that the property exists.
The property 'Devices' cannot be found on this object. Verify that the property exists.

Any suggestion?

TIA
.d

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 11:07 am
by Serhi
Hi denkteich

Did you try to run C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell\SyncHaDeviceAdvanced.ps1 ?

My result:
PS C:\Windows\system32> C:\Program Files\StarWind Software\StarWind\StarWindX\Samples\powershell\SyncHaDeviceAdvanced.ps1
HAImage1
Device synchronized

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 1:58 pm
by denkteich
Hi Serhi,

maybe this is not what i wanted.
the script is alway displaying synchronized.

i did the following thing:
- shutdown node 1
- copied lots of data to node 2
- ran script: synchronized, even if node 1 is not available
- started node 1
- ran script: synchronized, even while node 1 is synching the changes

how can i get this like the replication status, if it is resyncing or how much percentage is done?

cheers
.d

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 2:24 pm
by Boris (staff)
It looks like you are running the script against the current node's VSAN service.
To check whether a particular device is synchronized on all partner servers, you would need to adjust the script to check all of them.
how can i get this like the replication status, if it is resyncing or how much percentage is done?
This can be achieved by checking the HA device properties. Check the enumDeviceTarget.ps1 script for more details.

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 5:04 pm
by denkteich
i ran it on every node.
same result -> synchronized, even while still syncing.

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 6:08 pm
by Boris (staff)
Try using enumDevicesTargets.ps1: syncStatus 1 would mean "synchronized', 2- synchronizing, 3 - not synchronized.
You can access that by checking the following property of the device:

Code: Select all

$device.SyncState

Re: VSAN Free / Powershell / check sync state

Posted: Fri Jun 07, 2019 9:19 pm
by denkteich
Perfect, that was it I was looking for.

One more question:
how can I shorten it for only one device, not for all?

Re: VSAN Free / Powershell / check sync state

Posted: Sat Jun 08, 2019 3:51 pm
by Boris (staff)
something like:

Code: Select all

if ($device.Name -eq "HAImageX") { # where "X" is the number for that particular device (like HAImage1)
    $device.SyncState
}
should work for you.

Re: VSAN Free / Powershell / check sync state

Posted: Sat Jun 08, 2019 6:35 pm
by denkteich
perfect thx, i'll try with this.

Re: VSAN Free / Powershell / check sync state

Posted: Sun Jun 09, 2019 4:37 am
by Boris (staff)
You are welcome. Feel free to report how it goes for you.

Re: VSAN Free / Powershell / check sync state

Posted: Mon Jun 10, 2019 5:52 am
by denkteich
My SyncState.ps1 is ready.
Here it is:

Code: Select all

Import-Module StarWindX

try
{
    Enable-SWXLog

    $servers = @()

    $devicename = "HAImage1"
    $servers += New-SWServer 10.0.0.181 3261 root starwind
    $servers += New-SWServer 10.0.0.182 3261 root starwind

    foreach($server in $servers)
    {
        $server.Connect()
        write-host "Server:" $server.IP "-" $devicename -foreground yellow
        foreach($device in $server.Devices)
        {
            if ($device.Name -eq $devicename) {
                switch ($device.SyncStatus){
                    1 {$status = "synchronized"}
                    2 {$status = "synchronizing"}
                    3 {$status = "not synchronized"}
                    default {$status = "UNDEFINED"}
                }
                write-host "SyncStatus:" $status
                write-host "SyncPercent:" $device.SyncPercent "%"
            }
        }
        $server.Disconnect()
        write-host "-----------"
    }
}
catch
{
    Write-Host $_ -foreground red
}
finally
{    
} 

Re: VSAN Free / Powershell / check sync state

Posted: Mon Jun 10, 2019 4:18 pm
by Boris (staff)
Nice code. It looks to be what you were looking for.
And thanks for sharing this with the community.