Contact Info

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 PowerShell checks.

Most of the built-in checks have a PowerShell equivalent, implemented as a PowerShell (.ps1) script file. Out-of-the-box, each PowerShell script monitors the same items as the built-in check. Feel free to modify the script.

To add a new PowerShell-based Website monitoring check, do the following:

To customize the above monitoring check, click on the 'Edit button' next to the 'Script File' selection box. Notepad will be launched. You can now make changes to the PowerShell script.

Screenshot of a Powershell Website check

Website.ps1 script source code

#################################################################################
# ActiveXperts Network Monitor PowerShell script, © ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts 
# Network Monitor web site at https://www.activexperts.com
#################################################################################
# Script
#     CheckWebSite.ps1
# Description: 
#     Read data from a web page and search for a predefined pattern. 
#     This function uses the ActiveXperts Network Component, an ActiveXperts product.
#     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:
#     .\WebSite '<URL>' '<Text Pattern>'
# Sample:
#     .\WebSite 'www.activexperts.com:80/network-monitor/demopage' 'Welcome to ActiveXperts Demo Page'
#################################################################################

# Parameters
param
  (
    [string]$strUrl,
    [string]$strPattern
  )

cls

# Checks if the parameters are ok
if ( [string]$strUrl -eq "" -or [string]$strPattern -eq "" -or $numMaxCpuUsage -eq "" )
{
  $res = "UNCERTAIN: Invalid number of parameters - Usage: .\WebSite.ps1 <URL> <Text pattern>"
  echo $res
  exit
}

# The script
$objHttp = new-object -comobject ActiveXperts.Http

$objHttp.Connect( $strUrl )

if ( $objHttp.LastError -ne 0 )
{
  return "UNCERTAIN: Web site is unavailable"
  exit
}  

$strData = $objHttp.ReadData()
if ( $objHttp.LastError -ne 0 ) 
{
  return "UNCERTAIN: No response received from remote server"
  $objHttp.Disconnect()
  exit
}
  
if ( $strData -Contains $strPattern -eq 0 )
{
  return "SUCCESS: Web site is available, text pattern found DATA: 1"
}  
else
{
  return "ERROR: Web site is available, text pattern not found DATA: 0"
}  

$objHttp.Disconnect()