| ' ====================================================' ' 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 |
0 Replies
Would you like to comment?
You must be a member. Sign In if you are already a member.