Advertisement
easternnl

Combine multiple BLG files from perfmon into one file

Jun 1st, 2016
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # remove old files
  2. if (test-path "counters.txt" ) { Remove-Item "counters.txt" }
  3. if (Test-Path "counters_filtered.txt" ) { Remove-Item "counters_filtered.txt" }
  4. if (Test-Path "allday.blg" ) { Remove-Item "allday.blg" }
  5.  
  6. $files = ls -Filter *.blg
  7.  
  8. $arguments = ""
  9.  
  10. foreach ($file in $files)
  11. {
  12.     write-host $file.Name
  13.  
  14.     $arguments += "$($file.name) "
  15.  
  16.    
  17.    
  18. }
  19.  
  20. $arguments += "-o allday.blg"
  21.  
  22. # combine all files
  23. Write-Host "** Combining all logs"
  24. write-host "relog $arguments"
  25.  
  26. Start-Process -Wait relog -ArgumentList $arguments
  27.  
  28. #relog $arguments
  29.  
  30.  
  31. # query the counters in the file
  32. Write-Host "** Querying counters"
  33. relog allday.blg -q -o counters.txt
  34.  
  35. # filter only counters needed server1 or server2
  36. Write-Host "** Filtering counters for only needed servers"
  37. gc .\counters.txt | where { $_ -ilike "*server1*" } | Out-File -FilePath "counters_filtered.txt" -Append -Encoding ascii
  38. gc .\counters.txt | where { $_ -ilike "*server2*" } | Out-File -FilePath "counters_filtered.txt" -Append -Encoding ascii
  39.  
  40. # strip useless counters from the allday file
  41.  
  42. write-host "Creating allday_filtered.blg"
  43. relog "allday.blg" -cf "counters_filtered.txt" -o "allday_filtered.blg"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement