One of the few missing features of Provisioning Services is a central PVS Write Cache monitoring facility, which allows measuring the size of the Target Side Write Cache files (Setting Cache on Client HD) from a central location. This would be very helpful during POCs and Pilots for estimating the storage requirements for the final infrastructure as well as for trend analysis during normal operations.

As such a functionality does not require tremendous coding skills, I spend some time today developing a little tool which should help until we get it as a proper PVS build-in feature.

I’m aware that there are multiple ways to achieve this and most of them are much more elegant than what I do, but I tried to come up with the most simple approach. So I decided to go for the good old Windows batch scripting, which is understood by most of the admins out there and just works… J

So the tool is comprised of two scripts and a file with all targets we’d like to monitor. The scripts are:

  • Check_Write_Cache_Size.cmd, which reads the targets.txt file line by line and calls the worker script (worker.cmd) with a parameter for the Write Cache file location (default is d:\.vdiskcache) and a second parameter that contains the name of the current target.  After the script went through all targets it will pause for 15 seconds and than start over.
  • Worker.cmd, which just reads the size of the .vdiskcache file (in bytes) and writes it together with some time and date information into a csv file. Hereby it will create a single file for every target device (that why we pass the computer name as a second parameter).

Both scripts assume to live inside the C:\Temp directory. If you don’t like that, just modify the relevant sections inside the scripts. Furthermore you need to run the scripts with an administrative user that is able to access the d$ share of the target devices. Finally you need to include all targets you’d like to monitor into the Targets.txt file. Each target need to be on a single line. Below you can find an example of the Targets.txt:

 

Targets.txt

Windows7PVS001

Windows7PVS002

Windows7PVS003

 

To start the monitoring it is easiest to start a command prompt as Administrator (in case you use UAC) and move your prompt into the C:\Temp directory. Then simply call the Check_Write_Cache_Size.cmd script.

 

Here are the scripts, but please keep in mind you need to test before running these in production. Furthermore please check the disclaimer at the end of the blog:

 

Check_Write_Cache_Size.cmd

ECHO OFF

:Start

for /F %%i in (C:\temp\targets.txt) do cmd /Q /c c:\temp\worker.cmd \\%%i\d$\.vdiskcache %%i

TIMEOUT /T 15 /NOBREAK

goto :Start

 

 

Worker.cmd

ECHO OFF

echo %date%;%time%;%~z1 >> C:\temp\%2.csv

 

After you stopped the script, you should see a single .csv file for every target. Each should look similar to the one below (please note that the size is in byte):

 

Windows7PVS001.csv

Fri 11/04/2011; 9:10:00.65;258114903

Fri 11/04/2011; 9:10:15.33;258114903

Fri 11/04/2011; 9:10:30.32;265324452

Fri 11/04/2011; 9:10:45.33;265328635

Fri 11/04/2011; 9:11:00.32;265328635

Fri 11/04/2011; 9:11:15.31;265328635

Fri 11/04/2011; 9:11:30.33;273693421

Fri 11/04/2011; 9:11:45.31;273720012

 

Now just open Excel and import the csv. Ensure to mark the semicolon as delimiter. Now you should be able to create some nice little graphs about the write cache size.

 

In case you’d like to get some more information about the PVS Write Cache, check my recent blogs (here and here).

 

Disclaimer Notice

This software / 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 software / 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 software / 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 software / sample code.  In no event should the software / code be used to support of 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 software / 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 software / code belongs to Citrix, any distribution of the 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 code.