Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript » Network Monitor » Xml

Xml.vbs - Xml monitor function for ActiveXperts Network Monitor

ActiveXperts Network Monitor ships with a powerful set of pre-defined checks. Each individual check has a static number of configuration items. To monitor other items, or to combine monitoring items, you can make use of custom VBScript checks.

Most of the built-in checks have a VBScript equivalent, implemented as a Function in a VBScript (.vbs) file. Out-of-the-box, each VBScript function monitors the same items as the built-in check. Feel free to modify a function. The VBScript check can be customized by editing the VBScript function.

To add a new VBScript-based Xml monitoring check, do the following:

To customize the above monitoring check, click on the 'Edit button' next to the 'File selection box'. Notepad will be launched. You can now make changes to the VBScript function(s).

Screenshot of a VBScript Xml query

Xml.vbs script source code

' ///////////////////////////////////////////////////////////////////////////////
' // ActiveXperts Network Monitor  - VBScript based checks
' //  ActiveXperts Software B.V.
' //
' // For more information about ActiveXperts Network Monitor and VBScript, please
' // visit the online ActiveXperts Network Monitor VBScript Guidelines at:
' //    https://www.activexperts.com/support/network-monitor/online/vbscript/
' // 
' ///////////////////////////////////////////////////////////////////////////////
'  

Option Explicit
Const  retvalUnknown = 1
Dim    SYSDATA, SYSEXPLANATION  ' Used by Network Monitor, don't change the names


' ///////////////////////////////////////////////////////////////////////////////

' // To test a function outside Network Monitor (e.g. using CSCRIPT from the
' // command line), remove the comment character (') in the following 5 lines:
' Dim bResult
' bResult =  QueryXml()
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"

' //////////////////////////////////////////////////////////////////////////////

' //////////////////////////////////////////////////////////////////////////////

Function QueryXml()
' Description:
'     This function queries cdcatalog.xml for CDs that have more than 12 songs 
'     If there is more than one record, the function is successfull.
' Parameters:
'     No parameters
' Usage:
'     QueryXml()
' Sample:
'     QueryXml()

On Error Resume Next
    Dim xmlDoc, x, colNodes, strCDs

    QueryXml            = retvalUnknown  ' Default return value
	SYSDATA         = ""             ' Not used by this function
    SYSEXPLANATION      = ""             ' Set initial value

    strProducts         = ""

    Set xmlDoc          = CreateObject("Microsoft.XMLDOM")
    xmlDoc.async        = "false"

    xmlDoc.load("C:\Program Files\ActiveXperts\Network Monitor\Samples\cdcatalog.xml")

    Set colNodes = xmlDoc.selectNodes("/catalog/cd[songs>12]")  

    For Each x in colNodes
        If( strCDs <> "" ) Then 
            strCDs = strCDs & ", "
        End If
        strCDs          = strCDs & x.SelectSingleNode("artist").text & "-" & x.SelectSingleNode("title").text
    Next

    If( strCDs <> "" ) Then
        SYSEXPLANATION  = "Following CDs were found: [" & strCDs & "]"
        QueryXml = True
    Else
        SYSEXPLANATION  = "No CDs found"
        QueryXml        = False
    End If
End Function