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 Ica 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 'Ica.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.
Ica.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 # Ica.ps1 # Description: # Establish a telnet session to a ICA server and validate its response # ICA servers always reply a #ICA# message when ready to establish a session # 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) strIcaServer - Host name or IP address of the ICA server # Usage: # .\Ica.ps1 '<Hostname | IP>' ################################################################################# # Parameters param ( [string]$strIcaServer ) cls ################################################################################# # Function ################################################################################# ################################################################################# function tcprecv { param ( [ref]$strAllRespons ) $strResponse = $null $bHasData = $null $bHasData = $objTcp.HasData() while ( $bHasData ) { $strResponse = $objTcp.ReceiveString() $bHasData = $objTcp.HasData() if( $strAllRespons.Value -ne "" ) { #.. to indicate a newline $strAllRespons.Value = $strAllRespons.Value + "`n`r" } $strAllRespons.Value = $strAllRespons.Value + $strResponse } } ################################################################################# function tcpsend { param ( [ref]$strCommand ) if ( $strCommand.Value -ne "" ) { $objTcp.SendString( $strCommand.Value ) } } ################################################################################# function checkTelnet { param ( $strServer, $numPort, $strCommand1, $strCommand2, $strCommand3, $strReceive ) # Define variables $strAllResponses = "" # Create object $objTcp = new-object -comobject ActiveXperts.Tcp # 1 means: raw, 2 means: telnet (see also ActiveXperts Network Component manual) $objTcp.Protocol = 2 $objTcp.Connect( $strServer, $numPort ) if ( ($objTcp.LastError -ne 0 ) -or ( $objTcp.ConnectionState -ne 3 ) ) { return "UNCERTAIN: Unable to connect to [" + $strServer + "]" # can be called even when there's no connection $objTcp.Disconnect() exit } #write-host $objTcp.HasData() $objTcp.Sleep( 2000 ) # Allow some time tcprecv([ref]$strAllResponses) tcpsend([ref]$strCommand1) tcprecv([ref]$strAllResponses) tcpsend([ref]$strCommand2) tcprecv([ref]$strAllResponses) tcpsend([ref]$strCommand3) tcprecv([ref]$strAllResponses) #write-host $strAllResponses $objTcp.Disconnect() if ( ($strAllResponses.ToUpper()) -match ($strReceive.ToUpper()) -eq $true ) { return "SUCCESS: Response=[" + $strAllResponses + "] DATA: 1" exit } else { return "ERROR: No response DATA: 0" exit } } ################################################################################# # The script itself ################################################################################# if ( [string]$strIcaServer -eq "" ) { $res = "UNCERTAIN: Invalid number of parameters - Usage: .\Ica.ps1 <hostname>" echo $res exit } checkTelnet $strIcaServer 1494 "" "" "" "ICA"