[hobbit] Query current host status via CLI

Milburn, John A. John.Milburn at illinois.gov
Mon Sep 11 22:46:44 CEST 2006


This is what we are using. It runs on one of the Citrix servers. The
others don't collect farm data.
It's not real pretty, but it does what we need.

BEGIN
'*******************************************************************
'*******************************************************************
'******************************************************************* 

'***********************************************************************
***
'
' VBScript Source File
'
' NAME: CITRIXALL.VBS
'
' AUTHOR: John A. Milburn
' DATE  : 02/04/05
'
'
'***********************************************************************
***
Option Explicit
'***********************************************************************
***

Const ForReading = 1
Const ForWriting = 2

Public Const wbemFlagReturnImmediately = &h10
Public Const wbemFlagForwardOnly = &h20

'On Error Resume Next

Dim strComputer
strComputer = "."

Dim strFileOut, blArgs
Dim lngResult, lngUsersOnFarm
lngResult = 0

strFileOut = "-ctxinfo"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFileOut) Then
 	fso.DeleteFile(strFileOut)
End If
Set fso = Nothing

lngUsersOnFarm = GetFarmUsers(strComputer)
lngResult = GetCitrixInfo(strComputer)

WScript.Quit lngResult
		
'***********************************************************************
***
'***********************************************************************
***
'***********************************************************************
***
'***********************************************************************
***
		
'***********************************************************************
***
' Function name: GetCitrixInfo
' Parameters: 
'
'***********************************************************************
***
Function GetCitrixInfo(strComputer)
'***********************************************************************
***
'	On Error Resume Next

  Dim strFarmName, strIPAddress, strLoginsEnabled,
strNumberOfActiveSessions
  Dim strNumberOfDisconnectedSessions, strNumberOfSessions,
strServerName
  Dim strServerType, strZoneName, strZoneRanking

  Dim objWMIService, colItems, objItem
  Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\Citrix")
  Set colItems = objWMIService.ExecQuery("SELECT * FROM
MetaFrame_Server", "WQL", _
                               wbemFlagReturnImmediately +
wbemFlagForwardOnly)

	Dim strOut
  strOut = ""
  For Each objItem In colItems
    strFarmName = objItem.FarmName
    strIPAddress = objItem.IPAddress
    strLoginsEnabled = objItem.LoginsEnabled
    strNumberOfActiveSessions = objItem.NumberOfActiveSessions
    strNumberOfDisconnectedSessions =
objItem.NumberOfDisconnectedSessions
    strNumberOfSessions = objItem.NumberOfSessions
    strServerName = objItem.ServerName
    strServerType = objItem.ServerType
    strZoneName = objItem.ZoneName
    strZoneRanking = objItem.ZoneRanking
  Next
  Set objItem = Nothing
  Set colItems = Nothing
  Set objWMIService = Nothing
  
  strZoneName = Right(strZoneName, Len(strZoneName) -
(InStr(strZoneName, Chr(34))))
  strZoneName = Left(strZoneName, (InStr(strZoneName, Chr(34)) - 1))

  strOut = strOut & "Farm Name      : " & strFarmName & vbLf
  strOut = strOut & "Farm users     : " & CStr(lngUsersOnFarm) & vbLf
  strOut = strOut & "IP Address     : " & strIPAddress & vbLf
  strOut = strOut & "Logins Enabled : " & strLoginsEnabled & vbLf
  strOut = strOut & "Sessions" & vbLf
  strOut = strOut & "        Active : " & strNumberOfActiveSessions &
vbLf
  strOut = strOut & "  Disconnected : " &
strNumberOfDisconnectedSessions & vbLf
  strOut = strOut & "         Total : " & strNumberOfSessions & vbLf
  strOut = strOut & "Server Type    : " & strServerType & vbLf
  strOut = strOut & "Zone Name      : " & strZoneName & vbLf
  strOut = strOut & "Zone Ranking   : " & strZoneRanking & vbLf
  strOut = strOut & vbLf
  strOut = strOut & strNumberOfActiveSessions & " users active" & vbLf
  strOut = strOut & vbLf
'  WScript.Echo strOut


	Dim fso, objFileOut
	Set fso = CreateObject("Scripting.FileSystemObject")

	Dim blRed, blYellow, blGreen
	blRed = False
	blYellow = False
	blGreen = True

'Set warning and error
  If strNumberOfActiveSessions > 20 Then
    blYellow = True
  End If

  If strNumberOfActiveSessions > 25 Then
  	blRed = True
  End If



  Set objFileOut = fso.OpenTextFile(strFileOut, ForWriting, True)
  If blRed Then
  	objFileOut.WriteLine "red Citrix Server Information"
  Else
    If blyellow Then
    	objFileOut.WriteLine "yellow Citrix Server Information"
    Else
    	objFileOut.WriteLine "green Citrix Server Information"
    End If
  End If

  objFileOut.WriteLine ""
  objFileOut.WriteLine strOut
  objFileOut.WriteLine ""
  objFileOut.Close

  Set fso = Nothing
  GetCitrixInfo = -1
  Exit Function

End Function
'***********************************************************************
***



'***********************************************************************
***
Function GetFarmUsers(strComputer)
'Server:
\\COSTERMSERV3\root\Citrix:Citrix_Server.ServerName="D8TERMSERV1"
'Zone: \\COSTERMSERV3\root\Citrix:Citrix_Zone.ZoneName="D8"
'***********************************************************************
***
  Dim lngUserCount, objWMIService, colItems, objItem
  Dim strThisServer, lngPtr, strThisComputer
  Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\Citrix")
  Set colItems = objWMIService.ExecQuery("SELECT * FROM
Citrix_ServersInZone", "WQL", _
                                         wbemFlagReturnImmediately +
wbemFlagForwardOnly)
  For Each objItem In colItems
    strThisServer = objItem.Server
    lngPtr = InStr(strThisServer, "=") + 2
    strThisComputer = Mid(strThisServer, lngPtr, (Len(strThisServer) -
lngPtr))
    lngUserCount = lngUserCount + GetUsersOnServer(strThisComputer)
  Next
  Set objItem = Nothing
  Set colItems = Nothing
  Set objWMIService = Nothing
  GetFarmUsers = lngUserCount
End Function
'***********************************************************************
***

'***********************************************************************
***
Function GetUsersOnServer(strThisComputer)
'***********************************************************************
***
  Dim objWMIService, colItems, objItem, lngNumberOfSessions
  Set objWMIService = GetObject("winmgmts:\\" & strThisComputer &
"\root\Citrix")
  Set colItems = objWMIService.ExecQuery("SELECT * FROM
MetaFrame_Server", "WQL", _
                               wbemFlagReturnImmediately +
wbemFlagForwardOnly)

  For Each objItem In colItems
'    lngNumberOfSessions = CLng(objItem.NumberOfSessions)
    lngNumberOfSessions = CLng(objItem.NumberOfActiveSessions)
'    lngNumberOfSessions = CLng(objItem.NumberOfDisconnectedSessions)
'    lngNumberOfSessions = CLng(objItem.NumberOfSessions)
  Next
  Set objItem = Nothing
  Set colItems = Nothing
  Set objWMIService = Nothing

  GetUsersOnServer = lngNumberOfSessions

End Function
'***********************************************************************
***
'*******************************************************************
'*******************************************************************
'******************************************************************* 
END


-----Original Message-----
From: Jeffcoat, Al [mailto:Al.Jeffcoat at orhs.org] 
Sent: Monday, September 11, 2006 9:59 AM
To: hobbit at hswn.dk
Subject: RE: [hobbit] Query current host status via CLI

There's a file in the contrib directory of the source distribution file
called citrix.zip.  We are using it with the bbwin client.

Al



-----Original Message-----
From: Enrico Morigi [mailto:emorigi at auslrn.net] 
Sent: Monday, September 11, 2006 8:49 AM
To: hobbit at hswn.dk
Subject: Re: [hobbit] Query current host status via CLI

hi,

where can i download the citrix plugin to get the users sessions?

thanks
enrico


To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk





This e-mail message and any attached files are confidential and are
intended solely for the use of the addressee(s) named above. If you are
not the intended recipient, any review, use, or distribution of this
e-mail message and any attached files is strictly prohibited. This
communication may contain material protected by Federal privacy
regulations, attorney-client work product, or other privileges. If you
have received this confidential communication in error, please notify
the sender immediately by reply e-mail message and permanently delete
the original message.  To reply to our email administrator directly,
send an email to:  postmaster at orlandoregional.org .  If this e-mail
message concerns a contract matter, be advised that no employee or agent
is authorized to conclude any binding agreement on behalf of Orlando
Regional Healthcare by e-mail without express written confirmation by an
officer of the corporation. Any views or opinions presented in this
e-mail are solely those of the author and do not necessarily represent
those of Orlando Regional Healthcare.

To unsubscribe from the hobbit list, send an e-mail to
hobbit-unsubscribe at hswn.dk





More information about the Xymon mailing list