This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Citrix XenApp 6.5 - Need to monitor "LoginsEnabled"

I need to be able to monitor Citrix XenApp servers to see if logins are enabled or disabled with WMI. I noticed this thread (Citrix ZenApp 6.5 - How to retrieve NumberOfActiveSessions and NumberOfDisconnectedSessions) and I tried to modify the template to fit my needs, but I ran into some problems. First, the WMI command that seems to work displays all the XenApp servers in the farm instead of just the server I want to query. Second, the "LoginsEnabled" value is not a number but instead displays as True or False. It looks like SAM was made to work with numerical statistics and not true/false text strings; when I tried to use the PowerShell monitor I kept getting NaN (not a number). Does anyone have any ideas on how I could make this work?

This command run on the server CXA01: Get-WmiObject -Namespace root\citrix -Class Citrix_Server

Displays this result:

__GENUS                      : 2

__CLASS                      : MetaFrame_Server

__SUPERCLASS                 : Citrix_Server

__DYNASTY                    : Citrix_Server

__RELPATH                    : MetaFrame_Server.ServerName="CXA01"

__PROPERTY_COUNT             : 11

__DERIVATION                 : {Citrix_Server}

__SERVER                     : CXA01

__NAMESPACE                  : root\citrix

__PATH                       : \\CXA01\root\citrix:MetaFrame_Server.ServerName="CXA01"

Domain                       : CITRIXDEV

FarmName                     : CITRIXDEV

IPAddress                    : 192.168.6.51

LoginsEnabled                : True

NumberOfActiveSessions       : 9

NumberOfDisconnectedSessions : 0

NumberOfSessions             : 9

ServerName                   : CXA01

ServerType                   : 1

ZoneName                     : \\CXA01\root\Citrix:Citrix_Zone.ZoneName="Default Zone"

ZoneRanking                  : 2

__GENUS          : 2

__CLASS          : Citrix_Server

__SUPERCLASS     :

__DYNASTY        : Citrix_Server

__RELPATH        : Citrix_Server.ServerName="CXA02"

__PROPERTY_COUNT : 7

__DERIVATION     : {}

__SERVER         : CXA01

__NAMESPACE      : root\citrix

__PATH           : \\CXA01\root\citrix:Citrix_Server.ServerName="CXA02"

Domain           : CITRIXDEV

FarmName         : CITRIXDEV

IPAddress        : 192.168.6.52

LoginsEnabled    : True

ServerName       : CXA02

ZoneName         : \\CXA01\root\Citrix:Citrix_Zone.ZoneName="Default Zone"

ZoneRanking      : 1

__GENUS          : 2

__CLASS          : Citrix_Server

__SUPERCLASS     :

__DYNASTY        : Citrix_Server

__RELPATH        : Citrix_Server.ServerName="CXA03"

__PROPERTY_COUNT : 7

__DERIVATION     : {}

__SERVER         : CXA01

__NAMESPACE      : root\citrix

__PATH           : \\CXA01\root\citrix:Citrix_Server.ServerName="CXA03"

Domain           : CITRIXDEV

FarmName         : CITRIXDEV

IPAddress        : 192.168.6.53

LoginsEnabled    : True

ServerName       : CXA03

ZoneName         : \\CXA01\root\Citrix:Citrix_Zone.ZoneName="Default Zone"

ZoneRanking      : 3

__GENUS          : 2

__CLASS          : Citrix_Server

__SUPERCLASS     :

__DYNASTY        : Citrix_Server

__RELPATH        : Citrix_Server.ServerName="CXA04"

__PROPERTY_COUNT : 7

__DERIVATION     : {}

__SERVER         : CXA01

__NAMESPACE      : root\citrix

__PATH           : \\CXA01\root\citrix:Citrix_Server.ServerName="CXA04"

Domain           : CITRIXDEV

FarmName         : CITRIXDEV

IPAddress        : 192.168.6.54

LoginsEnabled    : True

ServerName       : CXA04

ZoneName         : \\CXA01\root\Citrix:Citrix_Zone.ZoneName="Default Zone"

ZoneRanking      : 3

Thanks!

  • Within your script you should convert the boolean value to an integer in the statistic result. E.G true=1 false=0.

  • The goal is to be able to show the up/down status of XenApp farm logins in the Orion home dashboard. If a farm has 10 XenApp servers, and logins are disabled on member 7, then I want to have a component resource box on the dashboard that shows green lights next to all the farm members except member 7 which would show red. First, SAM needs to see if logins are enabled or disabled.

    I tried using the following script based on what I was able to find in other PowerShell application templates I here on Thwack and some trial and error on the XenApp servers.

    Script Arguments: $XA01

    Script Body:

    $XA01 = "CXA01"

    $result = Get-WmiObject -namespace "root\citrix" -ComputerName $XA01 -Credential ${CREDENTIAL} -query 'select LoginsEnabled from MetaFrame_Server'

    if ($result -match "True")

    {$answer = 1}

    else

    {$answer = 0}

    Write-Host 'Message.Login_Status_CXA01: ' "Login Status -" $XA01

    Write-Host 'Statistic.Login_Status_CXA01: ' $answer

    Here is what it shows in the SAM script editor:

    Message.Login_Status_CXA01:           Login Status - CXA01

    Statistic.Login_Status_CXA01:            0

    The problem is, it always returns 0. Even if I set it to match for "False". Clearly something is wrong with my script and looking into this further, I found some issues. If I make a variable with a string and then call the variable…

    PS C:\Users\chi127> $resultString = "Powershell Test"

    PS C:\Users\chi127> Write-Host $resultString

    Powershell Test

    PS C:\Users\chi127>

    Everything works properly. If I make a variable and load in a command I found that will display the LoginsEnabled status and call it back…

    PS C:\Users\chi127> $resultWMI = Get-WmiObject -namespace "root\citrix" -query 'select LoginsEnabled from MetaFrame_Server'

    PS C:\Users\chi127> Write-Host $resultWMI

    PS C:\Users\chi127>

    It doesn’t work. If I just call the variable without Write-Host, it does work…

    PS C:\Users\chi127> $resultWMI

    __GENUS          : 2

    __CLASS          : MetaFrame_Server

    __SUPERCLASS     :

    __DYNASTY        :

    __RELPATH        :

    __PROPERTY_COUNT : 1

    __DERIVATION     : {}

    __SERVER         :

    __NAMESPACE      :

    __PATH           :

    LoginsEnabled    : True

    PS C:\Users\chi127>

    I'm guessing the if/else logic does not work because the Get-WmiObject result does not store as a variable that if/else was designed to work with. Looking around online, I tried using "[string] = $resultWMI" to force it do store as a string but that didn't help either. As you can see, my knowledge of PowerShell is very limited.


    Since I cannot get the PowerShell script to work, I thought I would try the WMI monitor component that uses WQL. This query at first glance seems to work.

    select LoginsEnabled from MetaFrame_Server where LoginsEnabled = "True"

    When logins are enabled, the component shows as up/green. When logins are disabled, the component shows as unknown/gray instead of down/red. Is there any way to get a value of false to make the component down/red instead of unknown/gray?

    Since the WMI monitor did not work they way I need it to work I thought I would try event logs. Apparently XenApp writes to the Windows Event Log when logins are enabled and disabled. I have it set to trigger when it sees specific log IDs have entries with the string "Logon Control Mode change to mode: Prohibit logons only." This successfully marks the component as down/red when logins are disabled. Unfortunately SAM only marks it down for 10 minutes and then auto resets back to green/up. I see no way to put a reset condition into the event log component. This works fine for alerts but we want to show login status in the Orion dashboard. Having it reset after 10 minutes, even though logins are still disabled, is not what we want.

    At this point I am lost. What is the best way to be able to show in the Orion home dashboard the up/down login status of XenApp?

  • You were certainly on the right path with the script you referenced above. The WMI Monitor will not work for your needs since your query returns a string value, not a numeric value. I would recommend posting this script to the Script Lab‌ where the community script gurus generally frequent. They may be able to identify the issue with your script.

  • I'd be interested in monitoring this as well. Chi127, did you get this script working eventually?!

  • Same here... if a script turns up to monitor this it would be helpful for us as well.