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 Ping-axsocket 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 'Ping-axsocket.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.
Ping-axsocket.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: # Ping-axsocket.ps1 # Description: # Ping a remote host. Ping is based on ActiveXperts Network Component # Parameters: # 1) strHost - Hostname or IP address of the computer you want to ping # 2) nMaxTimeOut - Timeout in milliseconds # Usage: # .\Ping-axsocket.ps1 '<hostname | IP>' Timeout_MSecs # Sample: # .\Ping-axsocket.ps1 'www.activexperts.com' 160 ################################################################################# # Parameters param ( [string]$strHost, [int]$numMaxTimeOut ) cls # Check parameters input if ( $strHost -eq "" -or $numMaxTimeOut -eq "" ) { $res = "UNCERTAIN: Invalid number of parameters - Usage: .\ping-axsocket.ps1 <host | IPaddress> Timeout_MSecs" echo $res #exit } # Create ICMP object $objIcmp = new-object -comobject ActiveXperts.Icmp if( $objIcmp -eq $null ) { $res = "UNCERTAIN: Failed to load ActiveXperts.Icmp" echo $res #exit } # Ping - Maximum. timeout: 3000 ms $objIcmp.Ping( $strHost, 3000 ) if ( $objIcmp.LastError -ne 0 ) { $res = "UNCERTAIN: " + $objIcmp.GetErrorDescription( $objIcmp.LastError ) echo $res #exit } # Check duration if ( $objIcmp.LastDuration -gt $numMaxTimeOut ) { $res = "ERROR: Request from [" + $strHost + "] timed out, time=[" + $objIcmp.LastDuration + "ms] (>" + $numMaxTimeOut + "ms) DATA:" + $objIcmp.LastDuration echo $res #exit } $res = "SUCCESS: Reply from " + $strHost + ", time=[" + $objIcmp.LastDuration + "ms], TTL=[" + $objIcmp.LastTTL + "] DATA:" + $objIcmp.LastDuration echo $res #exit