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 Xml 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 'Xml.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.
Xml.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 # Xml.ps1 # Description: # This function queries cdcatalog.xml for CDs that have more than 12 songs # If there is more than one record, the function is successfull. # Parameters: # No parameters # Usage: # .\Xml.ps1 # Sample: # .\Xml.ps1 ################################################################################# $xmlDoc = new-object -comobject Microsoft.XMLDOM $xmlDoc.async = "false" #$xmlDoc echo's when called on so where fetching the result in a dummy variable, or else Network Monitor #wont handle the result correctly $dummy = $xmlDoc.load("C:\Program Files\ActiveXperts\Network Monitor\Samples\cdcatalog.xml") $strResult = "" $colNodes = $xmlDoc.selectNodes("/catalog/cd[songs>12]") $strCDs = "" Foreach ($x in $colNodes) { if( $strCDs -ne "" ) { $strCDs = $strCDs + ", " } $strCDs = $strCDs + $x.SelectSingleNode("artist").text + "-" + $x.SelectSingleNode("title").text } if( $strCDs -ne "") { $res = "SUCCESS: following CDs were found: [" + $strCDs + "]" echo $res exit } else { $res = "ERROR: No CDs found" echo $res exit }