Hi is there any way to automatically monitor the %...
# citrix-provisioning
p
Hi is there any way to automatically monitor the % of the PVS cache disk usage across the Citrix VDI desktops, without e.g. SCCM? We currently have 15gb cache disks.
j
Here's a function I added to @Sacha Thomet's health check script...
Copy code
Function Check-WriteCacheFreeSpace {
  param (
         [string]$computername = "$env:computername",
         [string]$wcdrive = "D"
        )
  $results = @()
  $ResultProps = @{
    WCdrivefreespace = "N/A"
    Output_For_HTML1 = "NEUTRAL"
    Output_To_Log1 = $null
    vdiskdifSize_inMB = "N/A"
    Output_For_HTML2 = "NEUTRAL"
    Output_To_Log2 = $null
  }
  Try {
    $HardDisk = Get-WmiObject Win32_LogicalDisk -ComputerName $computername -ErrorAction Stop -Filter "DeviceID='${wcdrive}:'" | Select-Object Size,FreeSpace 
    If ($HardDisk -ne $null) {
      $DiskTotalSize = $HardDisk.Size 
      $DiskFreeSpace = $HardDisk.FreeSpace 
      $CacheDiskGB=[Math]::Round(($DiskFreeSpace/1073741824),2)
      $PercentageDS = (($DiskFreeSpace / $DiskTotalSize ) * 100)
      $PercentageDS = "{0:N2}" -f $PercentageDS 
      If ([int]$PercentageDS -ge 15) {
        $ResultProps.Output_To_Log1 = "WCdrivefreespace: Disk Free is normal [ $PercentageDS % ]"
        $ResultProps.WCdrivefreespace = "$PercentageDS %"
        $ResultProps.Output_For_HTML1 = "SUCCESS"
      } ElseIf (([int]$PercentageDS -lt 15) -and ([int]$PercentageDS -ge 10)) {
        $ResultProps.Output_To_Log1 = "WCdrivefreespace: Disk Free is Low [ $PercentageDS % ]"
        $ResultProps.WCdrivefreespace = "$PercentageDS %"
        $ResultProps.Output_For_HTML1 = "WARNING"
      } ElseIf ([int]$PercentageDS -lt 10) {
        $ResultProps.Output_To_Log1 = "WCdrivefreespace: Disk Free is Critical [ $PercentageDS % ]"
        $ResultProps.WCdrivefreespace = "$PercentageDS %"
        $ResultProps.Output_For_HTML1 = "ERROR"
      } ElseIf ([int]$PercentageDS -eq 0) {
        $ResultProps.Output_To_Log1 = "WCdrivefreespace: Disk Free test failed"
        $ResultProps.WCdrivefreespace = "$PercentageDS %"
        $ResultProps.Output_For_HTML1 = "ERROR"
      } Else {
        $ResultProps.Output_To_Log1 = "WCdrivefreespace: Disk Free is Critical [ $PercentageDS % ]"
        $ResultProps.WCdrivefreespace = "$PercentageDS %"
        $ResultProps.Output_For_HTML1 = "ERROR"
      }
    } Else {
      #
    }
  }
  Catch [system.exception] {
    #$_.Exception.Message
  }
  $ErrorActionPreference = "stop"
  Try {
    If (Test-Path "filesystem::\\$computername\$wcdrive`$\vdiskdif.vhdx") {
      $ResultProps.vdiskdifSize_inMB = (Get-ChildItem "\\$computername\$wcdrive`$\vdiskdif.vhdx").Length/1024/1024
      $ResultProps.Output_To_Log2 = "vdiskdifSize: The `"vdiskdif.vhdx`" size is $($ResultProps.vdiskdifSize_inMB) MB"
    } Else {
      $ResultProps.Output_To_Log2 = "vdiskdifSize: The `"vdiskdif.vhdx`" file cannot be reached"
    }
  }
  Catch [system.exception] {
    #$_.Exception.Message
    $ResultProps.Output_To_Log2 = "Unable to connect via UNC path"
  }
  $ErrorActionPreference = "Continue"
  $results += New-Object PsObject -Property $ResultProps
  return $results   
}
❤️ 1
Here's what it looks like in the report. See the last two columns before the NVIDIA license check.
👍 1
You can also use uberAgent. Many different ways to monitor this. You want both free space on the drive AND the size of the vdiskdif.vhdx itself. In my opinion 15GB is way too small. I personally always go with 50GB minimum.
m
I used to use SNMP with PRTG. PRTG would alert me when a disk was low.
j
Is it the same than what PVS systray icon shows? Usage of the Write cache. As WC can reuse the white space (delete data, etc), just getting the disk space usage is great but not totally accurate. I couldn't find a PVS counter for this.
j
I don't think there is a way to get white space. Interesting though. I just find that monitoring the size of the vdiskdif.vhdx itself is enough. @Yuhua Lu, is there a way to get the white space in the PVS write cache?
y
Yes, we report free space of write cache disk and cache file size to Director, don't remember if we report them locally. @Simon Graham ?
👀 1
s
We dont report free space on the cache disk -- but you can easily get that from Windows. You can retrieve information on the cache setup though:
Not sure what specifically you mean by "white space"?
j
@Simon Graham, does space in the vdiskdif.vhdx become available when files are deleted from C: ? I guess that's what we mean about white space or unused space. There is not much documented about this, so really unsure.
j
Yes that's what I meant, thanks Jeremy. It is supposed to do that. So the size of the vdiskdiff.vhdx is not a true reflection of the real space available inside it.
👍 1
s
So... that's actually a tricky question... Remember the cache is just disk blocks -- it's entirely up to NTFS and Windows to manage the space and either reuse deleted blocks or leave them as free for later on - the cache driver has no idea of this. The cache does support TRIM which can reduce the size of the cache file BUT only if the TRIM'd blocks are at the end of the cache file. The layout of the cache disk is VHDX format and the last block in the file is typically just the last disk block written - so TRIM can reduce the size if you create new blocks then immediately delete and TRIM them before any other new blocks are written.
j
@Simon Graham that's great information to help with our understanding. Thank you.
j
Thanks Simon, if my memory serves me right, earlier PVS version couldn't trim, claim back space at all. So there is still some integration from PVS to Windows mechanism. As if it was only Windows, no PVS, it can claim back any free block.
s
Yes windows can reuse any free block on a disk -- it can also issue TRIM to actually free blocks at the hardware level. Given the implementation of the PVS cache, our TRIM support can only actually delete blocks from the cache file if they are at the end of the file (by truncating the cache file and adjusting the VHDX metadata describing blocks that are present).
👍 2
j
Thank you Simon for this extra info, very useful to understand!
👍 1