Skip to content

Instantly share code, notes, and snippets.

@abarnas
Created October 12, 2011 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abarnas/1282557 to your computer and use it in GitHub Desktop.
Save abarnas/1282557 to your computer and use it in GitHub Desktop.
Monitis Top GetInternalAgents
Function GetInternalAgents(aObjHttp, aObjAgents, aShowMonitors, aShowProcesses)
Dim objAgents, xmlAgents
Set objAgents = CreateObject("Scripting.Dictionary")
'Retrieve the list of agents
url = "http://www.monitis.com/api?action=agents&apikey=" + apiKey + "&output=xml"
aObjHttp.open "GET", url, False
aObjHttp.send
'Parse response
Set xmlAgents = CreateObject("Microsoft.XMLDOM")
xmlAgents.async = False
xmlAgents.LoadXML(aObjHttp.responseText)
If xmlAgents.parseError.errorCode <> 0 Then
wscript.Echo xmlAgents.parseError.errorCode
wscript.Echo xmlAgents.parseError.reason
wscript.Echo xmlAgents.parseError.line
End If
'Retrieve the agent information for each agent
For Each agent in xmlAgents.documentElement.childnodes
'Create an InternalAgent Object
Set IntAgent = New class_InternalAgent
IntAgent.Id = agent.selectSingleNode("id").text
IntAgent.Name = agent.selectSingleNode("key").text
'Retrieve the agent information
url = "http://www.monitis.com/api?action=agentInfo&apikey=" + apiKey + "&output=xml&agentId=" + IntAgent.Id + "&loadTests=true"
aObjHttp.open "GET", url, False
aObjHttp.send
Set xmlAgentInfo = CreateObject("Microsoft.XMLDOM")
xmlAgentInfo.async = False
xmlAgentInfo.LoadXML(aObjHttp.responseText)
For Each info in xmlAgentInfo.documentElement.childnodes
If aShowProcesses.Count = 0 Then
GetGlobalMonitors aObjHttp, info.childnodes, IntAgent, aShowMonitors
Else
If LCase(info.nodename) = "processes" Then
GetProcessMonitors aObjHttp, info.childnodes, IntAgent, aShowProcesses
End If
End If
Next
'Add the agent object to the list of agents
aObjAgents.Add IntAgent.Id, IntAgent
Next
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment