Thursday, February 20, 2014

Exposing PVS data for BGinfo and Edgesight

Using Edgesight in a 6.5 environment with PVS, there are some conditions that need to be alerted on.  The quick and dirty way to get there is using an event log entry.  Described below is a startup script to capture PVS disk data in the event log and an environment variable.

To start, you need an event log source to use.  Creating a source is easy via powershell.  

New-EventLog –LogName Application –Source “Xenapp_Custom”

Technically you only need to this once, but it fails cleanly, allowing the command to be issued multiple times.

Set Some Defaults:

$disk="ID not found"

Read the data:

if(Test-Path $File){
$data=get-content $file
Foreach ($line in $data) {
if ($line.Contains("DiskName")){$iname=$line.replace("$","").replace("DiskName=","").replace(".vhd","")}
if ($line.Contains("WriteCacheType")){$wc=$line.replace("$","").replace("WriteCacheType=","")}

Evaluate the Vdisk mode and log it if we are unhappy:

switch ($wc)
"0" {$wc1="Private"}
"4" {$wc1="Standard"}
"1" {$wc1="Server";Write-EventLog –LogName Application –Source “XenApp_Custom” –EntryType Error –EventID 911 –Message “PVS ALERT. VDisk is set to Cache on server.  Immediate action is required to prevent an outage if this is a PROD image. Image: $iname”}
default {$wc1="OTHER";Write-EventLog –LogName Application –Source “XenApp_Custom” –EntryType Warning –EventID 911 –Message “PVS ALERT. Nonstandard VDisk configuration has been detected. Image: $iname”}

Capture the exception of a non PVSed disk

ELSE {$disk=$env:computername + "_Local"}

Write it to an environment variable so BGinfo can consume it and put it in the background


Like magic...

No comments:

Post a Comment