Virtual Disk Repair Times

On S2D Clusters, here is a small code snippet that I find useful to see how Virtual Disk repairs are going after rebooting a node or replacing a disk. It will also attempt to estimate the remaining time left (shout-out to Russell Workman for that addition):

while($true) { Get-VirtualDisk | Sort-Object FriendlyName | ft FriendlyName, OperationalStatus, HealthStatus ; Get-StorageJob | Sort-Object Name | ? { $_.JobState -notlike 'Completed' } 

$jobs = Get-storagejob | ? { $_.Name -like "*repair" -or $_.Name -like "*regeneration" }
$BytesProcessed = ($jobs.BytesProcessed | measure-Object -sum).sum
$BytesTotal = ($jobs.BytesTotal | measure-Object -sum).sum
$runningJobs = $jobs.count
$overallpercent = $BytesProcessed / $BytesTotal
if ($overallpercent -gt 0) 
   {
     $longestElapsedTime = ($jobs.ElapsedTime | select -First 1).TotalSeconds
     $remainingSeconds = ($longestElapsedTime / $overallpercent) - $longestElapsedTime
     $now = Get-Date
     $estimatedFinish = $now.AddSeconds($remainingSeconds)
     write-host "Estimated finish: $estimatedFinish" -foregroundcolor blue
     write-host "Current Time: $now" -foregroundcolor green
   }
else 
   {
     write-host "zero bytes processed, cannot estimate" -foregroundcolor red
   } 

sleep 2 ; Clear-Host }

2 thoughts to “Virtual Disk Repair Times”

Leave a Reply

Your email address will not be published. Required fields are marked *