# Run osverifydb on an ObjectStore-database parallel with multiple instances verifying one segment per process. # # Parameters: # 1. The database is a mandatory-parameter, ie. when not provided the script will ask for it. # 2. The number of processes can be provided, default is 10. # 3. The target directory for the logfiles, script will ask if not provided; note: current dir . will not work # # Copyright ClassiX Software GmbH, Hamburg, 2012 # Param( [Parameter(Mandatory=$true)] [String] $Database, $MaxThreads = 10, [Parameter(Mandatory=$true)] [String] $TargetDir ) Write-Host "Running osverifydb on database $Database with $MaxThreads parallel instances." Write-Host "Logfiles are created in $TargetDir" Write-Progress -Activity "osverifydb" -Status "collecting segments" $Segments = @() ossize $Database | where { $_.StartsWith("Data segment") } | % { $_.Substring("Data Segment ".Length) } | % { $_.Substring(0, $_.Length - 1) } | % { $Segments += $_ } [console]::TreatControlCAsInput = $true $SleepTimer = 200 $i = 0 $Segments | % { # Check to see if there are too many open threads # If there are too many threads then wait here until some close While ($(Get-Job -state running).count -ge $MaxThreads) { Start-Sleep -Milliseconds $SleepTimer if ([console]::KeyAvailable) { $key = [system.console]::readkey($true) if (($key.modifiers -band [consolemodifiers]"control") -and ($key.key -eq "C")) { "Terminating..." Get-Job | Stop-Job Remove-Job * exit } } } $ScriptBlock = { Param([string]$segNo, [string]$Db, [string]$dir) $File = "osverifydb_$segNo.log" "*****************************************************" | Out-File $dir\$File " osverifydb -F -limit 999999 -segment_n $segNo $Db" | Out-File $dir\$File -Append "*****************************************************" | Out-File $dir\$File -Append osverifydb -F -limit 999999 -segment_n $segNo $Db >> $dir\$File } $i++ $Job = Start-Job $ScriptBlock -ArgumentList @($_, $Database, $TargetDir) Write-Progress -Activity "osverifydb" -Status "Verifying" -PercentComplete ($i / $Segments.count * 100) } Write-Host "Waiting for the last jobs to complete..." # Wait for all to complete Get-Job -State Running | Wait-Job | Out-Null Write-Host "All jobs completed." # Display output from all jobs Get-Job | Receive-Job # Cleanup Remove-Job * # Report all osverifydb-segments that were not completed: Write-Host "The following Segments were not correctly analyzed (osverifydb stopped):" Get-ChildItem $TargetDir\osverifydb_*.log | ForEach-Object { if (!(Get-Content $_ | Select-String "pages")) { $_ } } Write-Progress -Activity "osverifydb" -Status "Verifying" -Completed .\osverifydb_analyze $TargetDir