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 Rsh 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.

Powershell Rsh check

Rsh.ps1 script source code

#################################################################################
# ActiveXperts Network Monitor PowerShell script, (c) ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts 
# Network Monitor web site at https://www.activexperts.com
#################################################################################
# Script
#     Rsh.ps1
# Description:
#     Run a command on a remote UNIX/LINUX machine. Success or Failure is determined by
#     the standard output of the RSH command.
#     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) strHost - Specifies the remote host on which to run the command
#     2) strUser - Specifies ther user name to use on the remote host.If omitted, the user name
#         if the Network Monitor service is used.
#     3) strCommand - Specifies the command to run
#     4) numTimeOut - Specifies how long (in milliseconds) to wait for the completion of the command
#     5) strPattern - Text pattern to search for in the standard output.
# Usage:
#      .\Rsh.ps1 '<strHost>' '<strUser>' '<strCommand>' <nTimeOut> '<strPattern>'
# Sample:
#      .\Rsh.ps1 'unix03', 'admin', 'ls -l /dev', 10000, 'floppy' 
#################################################################################

#parameters
param
(
  [string]$strHost,  
  [string]$strUser,
  [string]$strCommand,
  [int]$nTimeOut,
  [string]$strPattern
)

if ( ([string]$strHost -eq "") -or
     ([string]$strUser -eq "") -or
     ([string]$strCommand -eq "") -or
     ([int]$nTimeOut -eq "") -or
     ([string]$strPattern -eq "")
   )
{
  $res = "UNCERTAIN: Invalid number of parameters - Usage: .\Rsh.ps1 '<strHost>' '<strUser>' '<strCommand>' <nTimeOut> '<strPattern>'"
  echo $res
  exit
}

$objRsh = new-object -comobject ActiveXperts.Rsh

$objRsh.Clear()
$objRsh.Host = $strHost
$objRsh.UserName = $strUser
$objRsh.Command = $strCommand
$objRsh.ScriptTimeOut = $nTimeOut

$objRsh.Run()

if ( $objRsh.LastError -ne 0 )
{
  $res = "UNCERTAIN: #" + $objRsh.LastError + " : " + $objRsh.GetErrorDescription( $objRsh.LastError )
  echo $res
  exit
}

if ( $objRsh.StdErr -ne "" -and $objRsh.StdOut -eq "" )
{
  if ( $objRsh.stdErr.Length > 200 )
  {
    $res = "UNCERTAIN: Standard Error: " + $objRsh.StdErr.substring(0,200)
    echo $res
  }
  else
  {
    $res = "UNCERTAIN: Standard Error: " + $objRsh.StdErr
    echo $res
  }
  exit
}

if ( $objRsh.StdOut.contains($strPattern) -eq 1 )
{
  $res = "SUCCESS: Pattern[" + $strPattern + "] matched in RSH Standard Output"
  echo $res
  exit
}
else
{
  $res = "ERROR: Pattern[" + $strPattern + "] not matched in RSH Standard Output"
  echo $res
  exit
}