Free Citrix Monitoring – XenDesktop 7.13 Broker Community Update

Free Citrix Monitoring – XenDesktop 7.13 Broker Community Update

Free Citrix Monitoring – XenDesktop 7.13 Broker Community Update

This post has already been read 2437 times!

I have been working on a community monitoring project for a little while now that is aiming to provide you with a free platform to get a high level overview of your Citrix Estate.  As I have said before, the aim of this is not to compete with the likes of ControlUp etc as they do a great job of giving you a detailed look at what is happening on your estate.  The purpose of this is to give you a quick and easy way to see an Up/Down view of your platform and the supporting components.

The current modules that are available are:

  • Citrix Licensing
  • Citrix XenServer (Hosts and Pools)
  • Citrix StoreFront
  • Citrix NetScaler and vServer Status
  • Citrix Director
  • Citrix Workspace Environment Management

Today I am please to share that the second community update has been put into the framework. Citrix XenDesktop Controllers

I had an email from James Kindon all the way down in Wollongong in New South Wales requesting the monitoring scripts and also saying that he would be happy to assist and help with some of the modules.  After a few emails back and forth he asked to take on the XenDesktop Controller part of the framework.

The initial issue was time zones and email – was taking far too long to get responses back and forward.  Twitter to the rescue! Way easier to communicate, and by the screen shot below – something of a first for James :o)

If you want to follow James his handle is @james_kindon

So, onto the module.

the controller.ps1 file can be bolted onto the existing platform, take in the list of controllers from the registry and will check the following:

  • Controller Server Availability
  • Controller Broker Port Availability
  • Critical XenDesktop Controller Service Status

There is a pre-req for this function running completely and that is the Broker SDK needs to be installed on the monitoring server.

You can find this on the XenDesktop installation CD in the following location:

x64\Citrix Desktop Delivery Controller

If you decide not to install this the module will still run ok however if there is a service error the framework will not be able to determine the Site and Zone that the broker is active in.

Once you have the module you will also need to add the following 4 registry items

  • ControllerPort – The Port that the XML Broker is configured on
  • Controllers – A list of XenDesktop Controllers you want to test
  • ControllerServices – A comma delimited list of critical brokering services you want to test
  • ControllerTitle – The Controller Graph Title

We did think about having a single XenDesktop Controller from each site and have the module enumerate all the other controllers from that site.  However, if that main controller fails the monitoring would not be able to get to the rest of the controllers and would show the site down, even if this is not the case.

The code to test the XenDesktop Controllers can be found at the bottom of this article for reference but if you want a complete copy of the code including all the modules then just drop me an e-mail and I will send out the latest ShareFile link for you to download the code.

I have to say that this is a great example of the Citrix Community and the willingness of its members to help and collaborate with each other.  The simple fact that James and I have managed to produce a Powershell module to bolt into a wider monitoring framework using only email, Twitter and our own time is amazing!

If you want to get involved and pick off another part of the Citrix Monitoring stack then please feel free to drop me an email here.

Here is the monitoring in action.

First with a dummy server in

Also with a Brokering Service Failure showing the ability to decode the Site and Zone information

I am currently working on the PVS and Server Collection modules and hope to have them out in the next week or two.  If you want to get involved, just email!

Laters,

b@m

The Code

function TestCitrixControllers {

<# 
.SYNOPSIS 
 Tests Citrix XenDesktop Controllers Functionailty.
.DESCRIPTION 
 Tests Citrix XenDesktop Controllers Functionailty..
 Currently Testing
 Broker Availability
 Broker Port Connectivity
 All Services passed into the module
 Site and Zone Avability 
.NOTES 
 Name: TestCitrixControllers
 Author: James Kindon
 Date Created: 27/03/2017
.CHANGE LOG
 James Kindon - 27/03/2017 - Initial Script Creation 
 David Brett - 27/03/2017 - Edited logic of services test slightly 
 David Brett - 27/03/2017 - Added the XenDesktop SDK to get site name for broker machine
.LINK 
 @james_kindon
#>

#Initialize Arrays and Variables
 $ControllerUp = 0
 $ControllerDown = 0
 LogVerbose "Variables and Arrays Initalized" $VerboseFile "Green"

#Load the Citrix Broker Powershell SDK
 $ctxsnap = add-pssnapin citrix.broker*
 $ctxsnap = get-pssnapin citrix.broker*

if ($ctxsnap -eq $null) {
 LogError "XenDesktop Powershell Snapin Load Failed - No XenDesktop Brokering SDK Found" $ErrorLogFile
 $ctxsnap = "no"
 } else {
 LogVerbose "XenDesktop Powershell SDK Snapin Loaded" $VerboseFile "Green"
 $ctxsnap = "no"
 }

#Get Controller Server Comma Delimited List Port from Registry
 $Controllers = (Get-ItemProperty -path $Registry_Key -name Controllers).Controllers -Split ","
 $ControllerPortString = (Get-ItemProperty -path $Registry_Key -name ControllerPort).ControllerPort -Split ","
 $ControllerServices = (Get-ItemProperty -path $Registry_Key -name ControllerServices).ControllerServices -Split ","
 LogVerbose "Read in Controller List, Port from Registry" $VerboseFile "Green"
 LogVerbose "Controllers: $Controllers" $VerboseFile "Green"
 LogVerbose "Controller Port: $ControllerPortString" $VerboseFile "Green"
 LogVerbose "Controller Services: $ControllerServices" $VerboseFile "Green"

foreach ($Controller in $Controllers) {

#Test Connection To Controller Server
 $ControllerstatusTest = TestConnection($Controller)
 
 if ($ControllerstatusTest -eq "True") {
 
 #Server is up and responding to ping
 LogVerbose "$Controller is UP" $VerboseFile "Green"

#Check the Brokering Port
 $ControllerTest = TestNetConnection $Controller $ControllerPortString

if ($ControllerTest -eq "True") {
 #Controller broker port is up and running
 LogVerbose "$Controller Broker Port is UP: Port - $ControllerPortString" $VerboseFile "Green"
 
 #Get Broker Site and Zone Information for Error Logging
 $site = Get-BrokerSite -AdminAddress $Controller
 $SiteName = $site.Name
 LogVerbose "$Controller Site: $SiteName" $VerboseFile "Green"
 $zone = Get-BrokerMachine -AdminAddress $Controller
 $ZoneName = $zone.ZoneName
 LogVerbose "$Controller Zone: $ZoneName" $VerboseFile "Green"

#Check all critical service are running on the controller
 #Initalize Pre loop variables and set Clean Run Services to Yes
 $ServicesUp = "Yes"
 $ServiceError = ""

#Check Each Service for a Running State
 foreach ($Service in $ControllerServices) {
 $CurrentServiceStatus = CheckService $Controller $Service
 If ($CurrentServiceStatus -ne "Running") {
 #If the Service is not running set ServicesUp to No and Append The Service with an error to the error description
 if ($ServiceError -eq "") {
 $ServiceError = $Service
 } else {
 $ServiceError = $ServiceError + ", " + $Service
 }
 $ServicesUp = "no"
 }
 }

#Check for ALL services running, if so mark Controller as UP, if not Mark as down and increment down count
 if($ServicesUp -eq "Yes") {
 #The Controller and all services tested successfully - mark as UP
 LogVerbose "$Controller is UP and all Services and running" $VerboseFile "Green"
 $ControllerUp++
 } else {
 #There was an error with one or more of the services
 LogVerbose "$Controller Service error - $ServiceError - are degraded or stopped. Site: $siteName | Zone: $ZoneName" $VerboseFile "Red"
 LogError "$Controller Service error - $ServiceError - are degraded or stopped. Site: $siteName | Zone: $ZoneName" $ErrorLogFile
 $ControllerDown++
 }
 
 } else {
 #Controller Broker Port is down - mark down, error log and increment down count
 LogVerbose "$Controller Broker Port is DOWN - Port - $ControllerPortString. Site: $siteName | Zone: $ZoneName" $VerboseFile "Red"
 LogError "$Controller Broker Port is DOWN - Port - $ControllerPortString. Site: $siteName | Zone: $ZoneName" $ErrorLogFile
 $ControllerDown++
 }

} else {
 #Controller is down - not responding to ping
 LogVerbose "$Controller is DOWN" $VerboseFile "Red"
 LogError "$Controller is not responding to Ping" $ErrorLogFile
 $ControllerDown++
 }
 }

#Log To HTML File the StoreFront Server Monitoring Information
 $ControllerTitle = (Get-ItemProperty -path $Registry_Key -name ControllerTitle).ControllerTitle
 LogHTML "$ControllerTitle,$ControllerUp,$ControllerDown" $LogHTML

}

One thought on “Free Citrix Monitoring – XenDesktop 7.13 Broker Community Update

  1. Pingback: Free Citrix XenDesktop 7.13 Broker Monitoring

Leave a Reply

Your email address will not be published. Required fields are marked *