Skip to content

Instantly share code, notes, and snippets.

@ned1313
Created May 28, 2014 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ned1313/3d5b87583aaff901c1bc to your computer and use it in GitHub Desktop.
Save ned1313/3d5b87583aaff901c1bc to your computer and use it in GitHub Desktop.
Horizon View PCoIP Performance Data Collection
# Horizon View VM Data Collection Script
param(
#Log file location (uses current directory by default)
[string] $logfilelocation=".\",
#CSV file location (uses current directory by default)
[string] $csvfilelocation=".\",
#PoolID (leave blank for all pools)
[string] $poolID
)
#Create Export filename
$filename = Join-Path -Path $csvfilelocation -ChildPath "ViewVMStats_$(Get-date -f yyyy-MM-dd-hh-mm-ss).csv"
#Create log file
$logFile = Join-Path -Path $logfilelocation -ChildPath "VMStatisticsCollection_$(Get-date -f yyyy-MM-dd-hh-mm-ss).log"
#Get all VMs in all Pools or Pools specificed by ID
if($poolID){
$vms = get-pool -Pool_id $poolID | get-desktopVM
}
else{
$vms = get-pool | get-desktopVM
}
Add-Content $logFile -value ("$(get-date -f s) VMs loaded from all pools") -PassThru | Write-Host -ForegroundColor Yellow
#create stats variable
$vmstats = @()
Add-Content $logFile -value ("$(get-date -f s) Beginning Statistics retrieval") -PassThru | Write-Host -ForegroundColor Yellow
$prog = 0
$base = $vms.length
#get the statistics for each vm
foreach($vm in $vms){
Write-Progress -Activity "Collecting..." -PercentComplete (($prog/$base)*100) -CurrentOperation "$prog of $base complete" -Status "Please wait."
try{
$vmstats += Get-WmiObject -Namespace "root\cimv2" -ComputerName $vm.Name -Class Win32_PerfRawData_TeradiciPerf_PCoIPSessionNetworkStatistics -ErrorAction Stop
}
catch{
Add-Content $logFile -value ("$(get-date -f s) $($vm.Name) Collection Failed with Error $_") -PassThru | Write-Host -ForegroundColor Red
}
$prog++
}
#finish progress bar
Write-Progress -Activity "Collecting..." -Completed -Status "VM Stats collection complete."
#export results
Add-Content $logFile -value ("$(get-date -f s) Exporting Data to $filename") -PassThru | Write-Host -ForegroundColor Yellow
$vmstats | Export-Csv -Path $filename -NoTypeInformation
Add-Content $logFile -value ("$(get-date -f s) Quick Content") -PassThru | Write-Host -ForegroundColor Yellow
#show some quick stats on worst offenders
$topRXLoss = $vmstats | Sort-Object -Property RXPacketLossPercent -Descending | select __Server,RXPacketLossPercent,RXPacketLossPercent_Base -First 10
$topTXLoss = $vmstats | Sort-Object -Property TXPacketLossPercent -Descending | select __Server,TXPacketLossPercent,TXPacketLossPercent_Base -First 10
Write-Host -ForegroundColor Yellow "Top 10 RX Packet Loss"
$topRXLoss
Write-Host -ForegroundColor Yellow "`nTop 10 TX Packet Loss"
$topTXLoss
Write-Host -ForegroundColor Yellow "`nEnd of Script"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment