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 POP3 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 'Email-CheckPOP3.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.
Email-CheckPop3.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: # Email-CheckPop3.ps1 # Description: # Establish a telnet session to a POP3 mail server and validate its response # POP3 servers always reply a '+OK' 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) strPop3Server - Host name or IP address of the mail server # Usage: # .\Email-CheckPop3.ps1 '<Hostname | IP>' # Sample: # .\Email-CheckPop3.ps1 'pop3.activexperts.com' ################################################################################# # Parameters param ( [string]$strSmtpServer ) cls # Check paramters input if( ([string]$strSmtpServer -eq "")) { echo "UNCERTAIN: Invalid number of parameters - Usage: .\Email-CheckPop3.ps1 '<Hostname | IP>'" exit } ################################################################################# # The script itself ################################################################################# $objTcp = new-object -comobject ActiveXperts.Tcp $objTcp.Protocol = 2 $objTcp.Connect($strSmtpServer, 110) if ($objTcp.ConnectionState -ne 3) { $res = "Unable to connect to [" + $strSmtpServer + "]" echo $res $dummy = $objTcp.Disconnect exit } $bHasData = 1 While ($bHasData) { $newLine = $objTcp.ReceiveString() If ($newLine -ne "") { $content = $content + $newLine } else { $bHasData = 0 } } $result = $content -Match "OK" if ($result -eq 1) { $res = "SUCCESS: " } else { $res = "ERROR: " } $res = $res + "Responce=[" + $content + "]" echo $res exit