Skip to main content

 

Citrix Load Monitor

7 months ago
OfflinePaul Byers
Paul Byers
Description:  This is to monitor a custom load monitor configured in the Citrix Management console.   We set a custom load that figures in CPU, Memory and Number of sessions.  This allows for better load balancing of the Citrix servers.  Also is a more realistic account of the load of a server.
Language: VB Script/JScript
Code:

' ===================================================='
' TITLE:    CTXLoad.vbs                                                        '
' Author:...... Paul Byers                                                     '
' Date Created: Wed 9/21/2010                                                  '
' Last Modified:                                                               '
'         Modified By:                                                         '
'                   ******************************                             '
' PURPOSE:  Pulls Custom load Value in Citrix                                  '
'                   ******************************                             '
' RETURN:    Load percentage                                                   '
'                   ******************************                             '
' HOW TO USE:  Copy script into Whatsup performance counter                    '
'      Recommended to also Monitor Active Session count                                               '
'              (WMI performance counter -- Terminal Services \ Active Sessions)'
' =========================================================='
On Error Resume Next
'Sending log message to the WhatsUp Event Viewer
Context.LogMessage "Checking Address=" & Context.GetProperty("Address")

'Get the value of the reference variable A
Server = Context.GetProperty("Address")
User = Context.GetProperty("CredWindows:DomainAndUserid")
Pass = Context.GetProperty("CredWindows:Password")

'server = "CernpCtx14"
'User = "mcghi2\hiscripts"
'Pass =

'Test all values pulled in'
if len(Server)>0 and Len(User)>0 and Len(Pass)>0 then
   nGlobalError = 0
   sRet = ""
else
   nGlobalError = 1
   sRet = "User, Pass, or Server empty"
end if


if nGlobalError = 0 then
   Set Locator = CreateObject( "WbemScripting.SWbemLocator" )
   if Err.Number > 0 then
      nGlobalError = 1
      sRet = "Error creating SWbemLocator: " & Err.Number
   end if
end if

if nGlobalError = 0 then
   Set WMIService = Locator.ConnectServer(server, "\root\Citrix", User, Pass)
   if Err.Number > 0 then
      nGlobalError = 1
      sRet = "Error connecting to server: " & Err.Number
   end if
end if

if nGlobalError = 0 then
   Set collection = WMIService.ExecQuery(  "SELECT * FROM MetaFrame_Server_LoadLevel",,48)
   if Err.Number > 0 then
      nGlobalError = 1
      sRet = "Error with ExecQuery: " & Err.Number
   end if
end if

if nGlobalError = 0 then
   LoadLevel = 0

   For Each Item in collection
       LoadLevel = Item.LoadLevel
   Next

   B = clng(LoadLevel) /100
   A = B

   'Set the performance monitor value to graph
   Context.SetValue A
else
   Context.SetResult 1, sRet
End If

-----
You liked this too2 people like this discussion.
 
Concluded

0 Conclusions:

0 Replies

Would you like to comment?

You must be a member. Sign In if you are already a member.

  • 834 views
  • $obj.VersionIndex versions
  • 0 replies
  • 1 follower
     
Post Date:
September 21, 2011
Posted By:
Paul Byers

About this forum

  • 18,824 views
  • 14 topics
  • 3 followers
     

Viewed 834 times