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 Snmp 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 Snmp check

Snmp.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
#     Snmp.ps1
# Description: 
#     Connect to the (remote) SNMP agent, read the OID value and match it
#     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) strAgent - Host name or IP address of the (remote) SNMP agent
#     2) strCommunity - Community string. Default: 'public'
#     3) strOID - Retrieve value of this OID. 
#     4) strExpectedValue - Match retrieved value against this expected value
# Usage:
#     .\SNMP.ps1 '<Hostname | IP>' 'community name' '<x.x.x.x.x....>' '<expected value>'
# Sample:
#     .\SNMP.ps1 'localhost' 'public' '1.3.6.1.2.1.1.5.0' 'My Computer Name'
#################################################################################

# Parameters
param
  (
    [string]$strAgent,
    [string]$strCommunity,
    [string]$strOID,
    [string]$strExpectedValue
  )

cls

#################################################################################
# THE SCRIPT ITSELF
#################################################################################

if ( ( [string]$strAgent -eq "" ) -or 
     ( [string]$strCommunity -eq "" ) -or
     ( [string]$strOID -eq "" ) -or 
     ( [string]$strExpectedValue -eq "" )
   )
{
  $res = "UNCERTAIN: Invalid number of parameters - Usage: .\SNMP.ps1 <Hostname | IP> <community name> <x.x.x.x.x....> <expected value>"
  echo $res
  exit
}
  
# Create instance of SNMP object
$objSnmpManager     = new-object -comobject ActiveXperts.SnmpManager
$objConstants       = new-object -comobject ActiveXperts.ASConstants

# Initialize SNMP object
$objSnmpManager.ProtocolVersion = $objConstants.asSNMP_VERSION_V2C
$objSnmpManager.Initialize()

if ( $objSnmpManager.LastError -ne 0 )
{
  return "UNCERTAIN: Unable to initialize Network Component SNMP object"
  exit
}  

# Open connection to (remote) SNMP agent
$objSnmpManager.Open( $strAgent, $strCommunity )
if ( $objSnmpManager.LastError -ne 0 )
{
  return "UNCERTAIN: Unable to connect to agent [" + $strAgent + "] in [" + $strCommunity + "] community. Be sure SNMP agent is running"
  exit
}  

$objSnmpObject = $objSnmpManager.Get( $strOID )
if ( $objSnmpManager.LastError -ne 0 )
{
  return "UNCERTAIN: Unable to retrieve [" + $strOID + "]. . Be sure SNMP agent is running"
  exit
}

if ( $objSnmpObject.Value.ToUpper() -eq $strExpectedValue.ToUpper() )
{
  return "SUCCESS: Value read: [" + $objSnmpObject.Value + "], expected:[" + $strExpectedValue + "], Type:[" + $objSnmpObject.Type + "], DATA: 1"
}  
else
{
  return "ERROR: Value read: [" + $objSnmpObject.Value + "], expected:[" + $strExpectedValue + "], Type:[" + $objSnmpObject.Type + "], DATA: 0"
}  

# Note: type ID#s are described in Network Component manual, and included in Network Component samples.

$objSnmpManager.Close()
$objSnmpManager.Shutdown()