Posted in : Citrix, Virtual Apps and Desktops, Windows Server By Robert Skyllberg Translate with Google ⟶

3 years ago

In a recent use-case that I stumbled across, I wanted to monitor a few different things in a Citrix-environment with Provisioning Services technology.
In this specific blog-post I’ll show you how I configured monitoring for whether Rebalance Enabled is configured for active vDisk, with Provisioning Services (PVS) Powershell SnapIn.

Provisioning Services Powershell SnapIn

In case you don’t have Provisioning Services Powershell SnapIn configured already, you can read more about this here. This particular script is written with the Management Command Line Interface (MCLI).
When working with MCLI-SnapIn your regexp (Regular expression) knowledge will come in handy. I’ve only commented what my specific regexp replaces does in each section, I recommend taking help from the following sites in case you’re in need of assistance:

Scenario

For this case, we have different Device Collections in which I wanted to separately monitor using NRPE (Nagios Remote Plugin Execution). First off start with establishing a connection to your PVS server and predefining prerequisite parameters.

[cmdletbinding()]
Param(
    [string]$SiteName,
    [string]$CollectionName,
    [string]$StoreName
)
Begin{
    $exitCode = 0
    #Variables for MCLI connection setup
    $ServerName = hostname
    $ServerPort = "54321"
    #Connect to your Provisioning Service installation
    Add-PSSnapIn mclipssnapin
    Mcli-Run setupconnection -p server=$ServerName,port=$ServerPort >$null 2>&1
}

Below is the execution of what’s checked:

Process{
    $vDisk= ( (Mcli-Get DeviceInfo -p sitename=$SiteName,collectionname=$CollectionName -f diskLocatorName 2>$null) | Select-string "diskLocatorName" | Select-Object -First 1) -replace ".*:\s$StoreName\W"
    $CheckvDisk = ((Mcli-Get Diskinfo -p SiteName=$SiteName,StoreName=$StoreName,DiskLocatorName=$vDisk) | Select-string "rebalanceEnabled") -replace ".*:\s"
        if ($CheckvDisk -eq "0"){
        Write-Output "Critical - Active vDisk for collection $CollectionName has NOT Rebalance Enabled configured"
        Exit 2
        }
        elseif ($CheckvDisk -eq "1"){
        Write-Output "OK - Active vDisk for collection $CollectionName has Rebalance Enabled configured"
        Exit 0
        }
        else {
        Write-Output "Error - Check failed containing unexpected value"
        Exit 3
        }
}
End{
    Write-Output $Output
    exit $exitCode
}

-replace ”.*$StoreName\W” cleans my outout
FROM diskLocatorName: Store Name\vDiskName
TO vDiskName
-replace ”.*:\s” cleans my output
FROM rebalanceEnabled: 1
TO 1
If you have any questions, feel free to email me at robert.skyllberg@xenit.se or leave a comment below.

Tags : Citrix; XenApp; XenDesktop, PowerShell, Provisioning Services

Personlig rådgivning

Vi erbjuder personlig rådgivning med författaren för 1400 SEK per timme. Anmäl ditt intresse i här så återkommer vi så snart vi kan.

Add comment

Your comment will be revised by the site if needed.