Monitoring XenApp with WMI – Part 2: Citrix Servers

In part 1 of this series I talked about the basics of the Citrix WMI providers. In this part, I will talk about getting all information about a XenApp server, like which farm it belongs to, what applications are published, etc.

Again, I will be using PowerShell to get the WMI classes. I will assume that you are logged in to the XenApp server to do the WMI calls. But all of these calls can be done from another server (as long as you have the correct permissions and WMI isn’t blocked by a firewall). See part 1 to get more information about remote WMI calls.

Basic server information

Like I told in part 1, all relevant WMI classes are part of the “root\citrix” namespace. Let’s start off with the “Metaframe_Server” class. This class contains some basic information about the server you’re connecting to (or logged on to). So log in to one of your XenApp servers and start PowerShell. Now execute this command:

Get-WmiObject -Namespace root\citrix -Class Metaframe_Server

This will output something like this:

Domain : LAB
FarmName : LabFarm
IPAddress : 10.1.1.42
LoginsEnabled : True
NumberOfActiveSessions : 1
NumberOfDisconnectedSessions : 0
NumberOfSessions : 1
ServerName : XASRV001
ServerType : 1
ZoneName : \\XASRV001\root\citrix:Citrix_Zone.ZoneName="Default Zone"
ZoneRanking : 1
PSComputerName : XASRV001

I intentionally left out some of the (not so interesting) properties. As you can see this command outputs:

  • Domain to which this server is joined
  • Name of the XenApp Farm
  • IP Address
  • Whether or not logons are enabled on this server
  • Active sessions
  • Disconnected sessions
  • Total sessions
  • Server name
  • Server type
  • Zone to which this server belongs (a bit obfuscated, but I will explain this property in a minute)
  • Zone ranking (zone datacollector election)

Zones

While most of the properties in the previous list are pretty self-explanatory, so let’s focus on the not-so-clear properties: ZoneName and ZoneRanking. ZoneRanking is easy: it’s the zone datacollect election preference. These are the corresponding values:

  1. Most preferred
  2. Preferred
  3. Default preference
  4. Not preferred

Now for the ZoneName; this is actually a “pointer” to the Citrix_Zone WMI class. In WMI, this is called an associator. You are able to see the name of the zone in the path: Default Zone. But to get the actual data from WMI which is available in the Citrix_Zone class, execute the following command:

$Server = Get-WmiObject -Namespace root\citrix -Class Metaframe_Server
Get-WmiObject -Namespace root\citrix -Query "Associators of {$Server} Where ResultClass=Citrix_Zone"

This will output the following information (again, only displaying relevant properties):

DataCollector    : \\XASRV001\root\citrix:Citrix_Server.ServerName="XASRV001"
NumServersInZone : 2
ZoneName         : DEFAULT ZONE
PSComputerName   : XASRV001

Note that the “PSComputerName” property is added by PowerShell, it’s the computer name of the XenApp server to which I made the WMI call. The information displayed:

  • Data collector of the zone (as WMI associator)
  • Number of servers in this zone
  • Name of the zone

These queries can also be executed the other way around: what servers are in my Default Zone? To find out, use the following commands:

$Zone = Get-WmiObject -Namespace root\citrix -Class Citrix_Zone -Filter "ZoneName = 'Default Zone'"
Get-WmiObject -Namespace root\citrix -Query "Associators of {$Zone} Where AssocClass=Citrix_ServersInZone"

This will output a list of XenApp servers which are added to this zone. Note 2 things:

  1. I’m using the -Filter option in Get-WmiObject to get the server for the “Default Zone” only
  2. The association class in the “Associators of” query is Citrix_ServersInZone. Note that Citrix_ServersInZone is an associator class, which contains something like foreign and primary keys (eg. it associates the Citrix_Zone class to certain Citrix_Server classes). Note that the result class would be Citrix_Server, not Metaframe_Server, since Metaframe_Server is ONLY the XenApp server you’re connected to with WMI, Citrix_Server is the complete list of all servers in your farm.

Folders

Information about folders and servers in those folders can be gathered using WMI too. You can get a list of all (server) folders using the WMI class “Citrix_ServerFolder”:his

Get-WmiObject -Namespace root\citrix -Class Citrix_ServerFolder

This will output a list of ALL folders (recursive) displaying the properties “FolderDN” and “FolderName”. Where “FolderDN” is the complete path (distinguished name) of that particular folder. Using this as a base, you can get a list of all servers in a folder. You can use the associator class Citrix_ServersInFolder for that, or use the result class Citrix_Server. To read about the difference between associator and result classes, check the Microsoft MSDN site.

To get the list of servers in the “Servers/XABA001” folder, you can do the following:

$Folder = Get-WmiObject -Namespace root\citrix -Class Citrix_ServerFolder -Filter "FolderDN='Servers/XABA001'"
Get-WmiObject -Namespace root\citrix -Query "Associators of {$Folder} Where AssocClass=Citrix_ServersInFolder"

This will output a list of XenApp servers in the specified folder.

So this part covers the basics about servers, zones and folders. In the next part, I will cover getting information about published applications.

3 thoughts to “Monitoring XenApp with WMI – Part 2: Citrix Servers”

  1. Hi,

    Firstly thanks for this great topic,

    I have a question, could you please give a small explanation between sessions, I mean between Total, Active and Disconnects sessions ?

    Thanks in advance,

    Kind regards,

    Ata

Leave a Reply

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

Complete the following sum: * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.