Skip to content

Instantly share code, notes, and snippets.

@abarnas
Created October 12, 2011 21:12
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/1282593 to your computer and use it in GitHub Desktop.
Save abarnas/1282593 to your computer and use it in GitHub Desktop.
Monitis Top GetProcessMonitor
Function GetProcessMonitors(aObjHttp, oNames, aObjAgent, aShowProcesses)
url = "http://www.monitis.com/api?version=2&apikey=" & apikey & "&output=xml&action=topProcessByCPUUsage&limit=50&detailedResults=true"
aObjHttp.open "GET", url, False
aObjHttp.send
Set oRes = CreateObject("Microsoft.XMLDOM")
oRes.async = False
oRes.LoadXML(aObjHttp.responseText)
Set oNode = oRes.selectSingleNode("data/tests")
For Each t In oNode.childnodes
Set oTest = t.selectSingleNode("testName")
If Not oTest Is Nothing Then
If ShowThisProcess(oTest.text, aShowProcesses) Then
'Create a new monitor object
Set Monitor = New class_Monitor
Monitor.Id = t.selectSingleNode("id").text
Monitor.Name = t.selectSingleNode("testName").text
Monitor.DisplayName = GetMonitorName(t.selectSingleNode("testName").text)
'Retrieve the results for this monitor
GetResult t, Monitor, SupportedMonitors.Item("process")
'Add the monitor to the list of agents
aObjAgent.MonitorList.Add Monitor.Id, Monitor
End If
End If
Next
End Function
'-------------------------------------------------------------------
Function ShowThisProcess(aProcess, aShowProcesses)
ShowThisProcess = False
For Each sp In aShowProcesses
If (InStr(LCase(aProcess), LCase(sp)) > 0) Or (sp = "all") Then
ShowThisProcess = True
End If
Next
End Function
'-------------------------------------------------------------------
Function GetResult(aNode, aMonitor, aFields)
arrValues = Split(aFields, "|")
For Each value In arrValues
'Split each value in the API field name and the suffix string
arrDetails = Split(value,",")
strValue = arrDetails(0)
strSuffix = arrDetails(1)
'Retrieve the result for the given counter
Set t = aNode.selectSingleNode(strValue)
If Not t Is Nothing Then
'Create a new metric object
Set Metric = New class_Metric
Metric.Name = strValue
Metric.Result = t.text & strSuffix
'Add the metric object to the current monitor object
aMonitor.MetricList.Add Metric.Name, Metric
End If
Next
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment