Documentation forServer & Application Monitor

Example 2: Use the SolarWinds MIB Database template

Another example of how you can use the PowerShell Script Monitor is included in the SolarWinds MIB Database template, which you can import from the SolarWinds online IT community, THWACK. It includes a script that calculates the age difference for a new database running on the Orion server by comparing creation dates in the MIB database.

To add this template to SAM, follow the steps in Import and export SAM templates.

Recommended configurations for this template include:

  • Use Local Host as the Execution mode.
  • Set the polling frequency to 24 hours (86400 seconds) or more.
  • Set the polling timeout value based on your Internet connection speed.

    The MIB database file download is over 200 MB.

This script includes extensive comments to define the steps taken, which include:

  • Set a temporary location and name for the MIB database.
  • Download and extract data from the zip file.
  • Compare the creation dates of the original and downloaded MIB databases.
  • Report back to SAM with a message and statistics.
  • Save the .cfg file.

Disclaimer: This script is not supported under any SolarWinds support program or service. Scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.

Here are some ways you can extend the provided code:

  • Add error trapping. For example, you could check and ignore, or respond with an error for negative values.
  • Add proxy and credentials code if your server is behind a proxy:

    # Create a Web Proxy
    $WebProxy = New-Object System.Net.WebProxy
    $WebProxy.Address = "http://proxy.address.local:80"
    # Create Credentials for Proxy
    $ProxyCreds = New-Object -TypeName System.Net.NetworkCredential
    $ProxyCreds.UserName = "ProxyUsername"
    $ProxyCreds.Password = "ProxyPassword"
    # Assign the Creds to the Proxy
    $WebProxy.Credentials = $ProxyCreds
    # Assign the Proxy to the Client
    $WebClient.Proxy = $WebProxy
  • Add code to clear out the saved .cfg file.

If the database does not fully update, use the Orion Permission Checker to verify permissions on the Orion server.