Submit a ticketCall us

Systems Monitoring for Dummies
Our new eBook will teach you the fundamentals and help you create monitors and alerts that are effective, meaningful, and actionable. Monitoring is more than a checkbox on your to-do list. This free eBook will give you practical advice to help you succeed in all aspects of monitoring – discovery, alerting, remediation, and troubleshooting. Don’t miss out on this indispensable resource for newbies, experienced IT pros, and everyone in between. Register Now.

Home > Success Center > Server & Application Monitor (SAM) > SAM Custom Template Guide > Example template: SolarWinds MIB Database

Example template: SolarWinds MIB Database

Table of contents

The SolarWinds MIB Database is a custom template using the Microsoft PowerShell script monitor. The script in this template calculates the age difference for a new database running on your Orion server by pulling the database and comparing creation dates.

Recommended configurations:

  • Polling frequency at 24 hours (86400 seconds) or higher
  • Polling timeout set depending on your Internet Connection speed

    For reference, the MIB Database file download is over 200 MB.

  • Execution mode: Local Host

    Running the Web Client code over remote PowerShell may cause issues.

The script code used in this PowerShell monitor include extensive comments to clearly define the steps taken. Overall, the script:

  • Sets a temporary location and names for the MIB database
  • Downloads and extracts data from the zip
  • Compares the creation date between the original and downloaded MIB database
  • Provides content back to SAM with a message and statistic data of the amount of days older than the original
  • Saves the .cfg file if you want to update it at a later time

The script used in the template is as follows:

$MibUrl = "http://downloads.solarwinds.com/solarwinds/Release/MIB-Database/MIBs.zip"
$LocalMib = "$( $env:ProgramData )\SolarWinds\Mibs.cfg"
			
# Temporary Location for working with the MIB
$MIBZip  = "$env:temp\MIBS.zip"
			
# Create a the name for the MIB.cfg file
$MIBCfg  = $MIBZip.Replace("zip", "cfg")
			
# Cleanup Temp Folder
Remove-Item -Path $MIBCfg -Force -ErrorAction SilentlyContinue
			
# Create new Web Client
$WebClient = New-Object System.Net.WebClient
			
# Download from $MibUrl to $MIBZip
$WebClient.DownloadFile($MibUrl, $MIBZip)
			
# Create Shell Object
$Shell = New-Object -com Shell.Application
$Location = $Shell.Namespace( $env:temp )
			
# Extract MIBs.cfg file from Zip File
$ZipFolder = $Shell.Namespace( $MIBZip )
$MibFile = $ZipFolder.Items() | Where-Object { $_.Name -eq "MIBs.cfg" }
$Location.CopyHere( $MibFile )
			
# Compare UTC Creation date on the newly downloaded and the original MIB.cfg
$DateNewFile = (Get-Item -Path $MIBCfg  ).CreationTimeUtc
$DateOldFile = (Get-Item -Path $LocalMib).CreationTimeUtc
$DaysOld = [int]( ( $DateNewFile - $DateOldFile ).TotalDays )
			
Write-Host "Message: MIB Database on $( $env:ComputerName ) is $( ( $DateNewFile - $DateOldFile ).TotalDays.ToString("0") ) days old"
Write-Host "Statistic: $( ( $DateNewFile - $DateOldFile ).TotalDays.ToString("0") )"
$ExitCode = 0
			
#Cleanup
Remove-Item -Path $MIBZip -ErrorAction SilentlyContinue
			
#We Leave the MIBs.cfg file in the $temp folder in case you want to update it.
exit $exitcode

You can import the template through SAM:

  1. On the Web Console, click Settings > All Settings > SAM Settings, and click Manage Templates.
  2. Click the Shared Templates on THWACK tab.

    A page opens and populates with available templates from THWACK.

  3. Enter SolarWinds MIB Database in the search field.
  4. Select a template file and click Import.
  5. Enter your THWACK account credentials when prompted.

    If you need an account, click Create Account and follow the steps.

  6. The SolarWinds MIB Database template imports into the Orion Web Console. In the dialog box, click View Imported Templates.

    A list displays with the imported template.

Options to extend the code:

  • Add error trapping to the script. 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 needed.

Troubleshooting

If the database does not fully update, you may have a permissions issue with the local file. Check the permissions of the downloaded .cfg file and temp directory with the Orion Permission Check, or manually. If you make changes, we recommend

 
Last modified

Tags

Classifications

Public