Created
January 6, 2018 04:53
-
-
Save rayterrill/b18b164d84c9798b01a154c69099cd3f to your computer and use it in GitHub Desktop.
Get VSAN Resync Status using SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires https://github.com/darkoperator/Posh-SSH | |
| function Get-VSANResyncStatus { | |
| param( | |
| [string]$esx_server, | |
| [String]$esx_username, | |
| [String]$esx_password | |
| ) | |
| $secpasswd = ConvertTo-SecureString $esx_password -AsPlainText -Force | |
| $credential = New-Object System.Management.Automation.PSCredential($esx_username, $secpasswd) | |
| New-SSHSession -ComputerName $esx_server -Credential $cred | Out-Null | |
| $output = Invoke-SSHCommand -SessionId 0 -Command "esxcli vsan debug resync summary get" | |
| $outputExploded = $output.output -split '[\r\n]' | |
| #get resyncing objects | |
| [regex]$regex = " Total Number Of Resyncing Objects: (\d+)" | |
| $m = $regex.Match($outputExploded[0]) | |
| $resyncingObjects = $m.Groups[1].value | |
| #get bytes left to resync | |
| [regex]$regex = " Total Bytes Left To Resync: (\d+)" | |
| $m = $regex.Match($outputExploded[1]) | |
| $bytesToResync = $m.Groups[1].value | |
| #get GBs left to resync | |
| [regex]$regex = " Total GB Left To Resync: (\d+)" | |
| $m = $regex.Match($outputExploded[2]) | |
| $gbsToResync = $m.Groups[1].value | |
| Write-Host "$($resyncingObjects) resyncing objects, $($bytesToResync) bytes to resync, $($gbsToResync) gbs to resync" | |
| } | |
| #Get-VSANResyncStatus -esx_server MYESXISERVER -esx_username root -esx_password MY_ROOT_PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment