Citrix script

Milburn, John John.Milburn at Illinois.gov
Fri Jun 29 17:07:49 CEST 2007


Try this

'**************************************************************************
Option Explicit
'**************************************************************************
Const ForReading = 1
Const ForWriting = 2
Public Const wbemFlagReturnImmediately = &h10
Public Const wbemFlagForwardOnly = &h20

On Error Resume Next

Dim strComputer
Dim strFileOut, blArgs
Dim lngResult

strComputer = "."
lngResult = 0
strFileOut = "-ctxinfo"

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


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

  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 & "Server Name    : " & strComputer & 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

End Function

-----Original Message-----
From: Michael Frey [mailto:Michael.Frey at aptconsulting.com] 
Sent: Friday, June 29, 2007 9:30 AM
To: hobbit at hswn.dk
Subject: RE: [hobbit] How to make defaults only for a subset of hosts 

I am trying to configure the tests included in citrix.zip.

Can someone explain how to get this test working?

Michael Frey.  Manager, Microsoft and Hosting Services.  APT Inc.  7540 Windsor Dr. Suite 204.  Allentown, PA 18195.
Ph. 610.366.1100, ext 15 Fax 610.366.7375
http://www.aptconsulting.comĀ  http://www.WebtrialZ.com



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





More information about the Xymon mailing list