Checking PVS targets for processes with high disk reads

Checking PVS targets for processes with high disk reads

book

Article ID: CTX475144

calendar_today

Updated On:

Description

In PVS environments when weak target device performance is encountered, slow boot, slow application opening, there are a several places to check for insights into the source of the problem.

One common source of weak target device performance is an unexpected volume of read requests from target devices. 
When all booted target devices are simultaneously requesting much larger volumes of reads than normal, it can lead to network saturation, network latency, PVS server over utilization, vdisk storage over utilisation.

When high load on PVS servers is determined as source of the problem, we want to quickly determine if there is a common process on PVS targets consuming reads. To simplify identifying a common source on target devices, a PowerShell script was created which will query PVS targets for the top read consuming processes.
 


Instructions

Powershell script example to be run from PVS server.

Replace <site> with the PVS site name, and replace <collection name> with target device collection

The script will query each target device in the device collection and return its up time, and top 5 processes by Reads in GB. 


& "$($env:systemroot)\Microsoft.NET\Framework64\v4.0.30319\installutil.exe" "$($env:programfiles)\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll"
Add-PSSnapin *PVS*

$targets = Get-PvsDevice -SiteName <site> -CollectionName <collection name> | select devicename, domainname

foreach ($target in $targets){
    $TargetName = "$($target.devicename).$($target.domainname)" 
    $TopReads = Get-CimInstance -ComputerName $TargetName -ClassName Win32_Process | Select-Object Name,ReadTransferCount | sort -Descending ReadTransferCount | select -First 5 
    $Uptime = (Get-Date) - (Get-CimInstance -ComputerName $TargetName -ClassName Win32_OperatingSystem).LastBootUpTime 
    Write-Output "`nPVS target name:`t$($TargetName)"
    Write-Output "Uptime: $($uptime.days) days, $($uptime.hours) hours, $($uptime.minutes) minutes"
    Write-Output "Processes currently running with top reads in GB:"
    foreach ($read in $TopReads){
        $ProcessName = "$($read.name)".Padright(25,' ')
        $ReadGB = $([math]::round(($read.ReadTransferCount)/1GB, 3))
        Write-Output "$ProcessName $ReadGB"
    }
}

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.