Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts Network Monitor ships with a large collection of PowerShell scripts and VBScript scripts to monitor and manage a network.

Use ActiveXperts Netork Monitor to monitor your virtualization servers, domains, computers and devices. It runs on a single Windows server, without agents required on the monitored systems. It has many built-in checks and also allows administrators to create custom checks using PowerShell, VBScript, WMI and SSH.


Website.ps1 - ActiveXperts Network Monitor PowerShell check

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:

  • On the 'Monitor menu', open 'New Monitoring Check (Script)' and choose 'New PowerShell Check'. The 'PowerShell Check' dialog box appears;
  • In the 'Script File' selection box, select 'Website.ps1';
  • In the 'Script Parameters'group box enter the required parameters. You can also load a working sample first by clicking on the 'Click here to load a sample' link.

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 http://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 '' ''
# 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  "
  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()