http.vbs - vbscript script by ActiveXperts Software
http.vbs read data from a web page and search for a pattern.
Use http.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select http.vbs. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
http.vbs script code
' ///////////////////////////////////////////////////////////////////////////////
' // ActiveXperts Network Monitor - VBScript based checks
' // For more information about ActiveXperts Network Monitor and VBScript, visit
' // http://www.activexperts.com/support/network-monitor/online/vbscript/
' ///////////////////////////////////////////////////////////////////////////////
Option Explicit
' Declaration of global variables
Dim SYSDATA, SYSEXPLANATION ' SYSDATA is displayed in the 'Data' column in the Manager; SYSEXPLANATION in the 'LastResponse' column
' Constants - return values
Const retvalUnknown = 1 ' ActiveXperts Network Monitor functions should always return True (-1, Success), False (0, Error) or retvalUnknown (1, Uncertain)
' // To test a function outside Network Monitor (e.g. using CSCRIPT from the
' // command line), remove the comment character (') in the following lines:
' Dim bResult
' bResult = CheckWebSite( "www.activexperts.com:80/network-monitor/demopage", "ActiveXperts" )
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"
Function CheckWebSite( strURL, strPattern )
' Description:
' Read data from a web page and search for a predefined pattern.
' This function uses ActiveXperts Network Component.
' ActiveXperts Network Component is automatically licensed when ActiveXperts Network Monitor is purchased
' For more information about ActiveXperts Network Component, see: www.activexperts.com/network-component
' Parameters:
' 1) strURL - URL of the web site, without http or https prefix
' 2) strPattern - Text pattern to search for in the specified site
' Usage:
' CheckWebSite( "<URL>", "<Text Pattern>" )
' Sample:
' CheckWebSite( "www.live.com", "Windows" )
Dim objHttp, strData
CheckWebSite = retvalUnknown ' Default return value, and will be shown as a yellow (uncertain) icon in the Manager
SYSDATA = "" ' SYSDATA displayed in the 'Data' column in the Manager
SYSEXPLANATION = "" ' SYSEXPLANATION displayed in the 'LastResponse' column in the Manager
Set objHttp = CreateObject("AxNetwork.HttpEx")
strData = objHttp.Get( strUrl )
If( objHttp.LastError <> 0 ) Then
CheckWebSite = False
SYSEXPLANATION = "No response received from remote server"
Exit Function
End If
If( InStr( strData, strPattern ) <> 0 ) Then
CheckWebSite = True
SYSEXPLANATION = "Web site is available, text pattern found"
Else
CheckWebSite = False
SYSEXPLANATION = "Web site is available, text pattern not found"
End If
End Function
