This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Monitor to return and parse web site data

I've been given a request from an application team.  With Solarwinds...

  • log into a specific URI, example:  companyapp/.../somedata  
  • pull back a date field from the /somedata directory (it's application license expiration date)
  • parse the data for # of days of license remaining
  • Solarwinds alert if # of days remaining is < 60 

Looking through the options available I have the feeling this will be a PowerShell monitor, not an HTTP monitor.  If I follow correctly I don't think the HTTP component monitor actually return data from a web site.  It's an up/down kind of monitor.

I welcome input from the community on the best way to accomplish the assigned task using Solarwinds.  Thanks.

Parents
  • I did something similar with PowerShell and IE. Here's some code to get you started.

    $min_days_to_expiration = 60
    $exitcode = -1
    $statistic = -1
    $message = ""
    $max_ready_wait_msecs = 1000
    $ready_wait_increment_msecs = 100
    $max_load_wait_secs = 10
    
    $uri = 'https://companyapp/details/moredetails/somedata'
    
    try {
     ## Create a new HTTP session and load the page
    
     $ie = New-Object -com InternetExplorer.Application 
     $ie.navigate($uri) 
    
     $wait_elapsed_msecs = 0
     while (($ie.readyState -ne 4) -and ($wait_elapsed_msecs -lt $max_ready_wait_msecs) ) {
     Start-Sleep -m $ready_wait_increment_msecs; 
     $wait_elapsed_msecs = $wait_elapsed_msecs + $ready_wait_increment_msecs 
     } # Waiting for page ready
    
     # Waiting for page data to populate
     Start-Sleep -s $max_load_wait_secs
    
     # Edit the line below to find the expiration date in your document.
     # If it's not wrapped in a tag with an ID attribute, regular expressions are your friend.
     $ExpirationDate = $ie.Document.getElementById("EventDate1").InnerText
    
     $System_TimeStamp=(Get-Date)
     Start-Sleep -s 10
    
     $TimeDiff_raw = NEW-TIMESPAN –Start $ExpirationDate –End $System_TimeStamp
     Start-Sleep -s 10
    
     $TimeDiff=[math]::Round($TimeDiff_raw.TotalDays,0)
     
     $statistic = $TimeDiff
     $message = "License expires in $TimeDIff days. Expiration date is $ExpirationDate ."
    
     if ( $TimeDiff -gt $min_days_to_expiration)
     {
     $exitcode = 0 #OK
     } else {
     $exitcode = 3 #Critical
     }
    } catch {
     # If table doesn't load or can't be parsed, return unknown status and message
     $message = "Could not get expiration date"
     $statistic = -1
     $exitcode = 4 #Unknown
    } finally {
     ## Close the session and destroy the IE object
     $ie.Quit()
     [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie)
     Remove-Variable ie
    }
    
    # Output message and statistic for Solarwinds, exit with exit code for Solarwinds
    Write-Host "Message: $message"
    Write-Host "Statistic: $statistic"
    exit $exitcode
Reply
  • I did something similar with PowerShell and IE. Here's some code to get you started.

    $min_days_to_expiration = 60
    $exitcode = -1
    $statistic = -1
    $message = ""
    $max_ready_wait_msecs = 1000
    $ready_wait_increment_msecs = 100
    $max_load_wait_secs = 10
    
    $uri = 'https://companyapp/details/moredetails/somedata'
    
    try {
     ## Create a new HTTP session and load the page
    
     $ie = New-Object -com InternetExplorer.Application 
     $ie.navigate($uri) 
    
     $wait_elapsed_msecs = 0
     while (($ie.readyState -ne 4) -and ($wait_elapsed_msecs -lt $max_ready_wait_msecs) ) {
     Start-Sleep -m $ready_wait_increment_msecs; 
     $wait_elapsed_msecs = $wait_elapsed_msecs + $ready_wait_increment_msecs 
     } # Waiting for page ready
    
     # Waiting for page data to populate
     Start-Sleep -s $max_load_wait_secs
    
     # Edit the line below to find the expiration date in your document.
     # If it's not wrapped in a tag with an ID attribute, regular expressions are your friend.
     $ExpirationDate = $ie.Document.getElementById("EventDate1").InnerText
    
     $System_TimeStamp=(Get-Date)
     Start-Sleep -s 10
    
     $TimeDiff_raw = NEW-TIMESPAN –Start $ExpirationDate –End $System_TimeStamp
     Start-Sleep -s 10
    
     $TimeDiff=[math]::Round($TimeDiff_raw.TotalDays,0)
     
     $statistic = $TimeDiff
     $message = "License expires in $TimeDIff days. Expiration date is $ExpirationDate ."
    
     if ( $TimeDiff -gt $min_days_to_expiration)
     {
     $exitcode = 0 #OK
     } else {
     $exitcode = 3 #Critical
     }
    } catch {
     # If table doesn't load or can't be parsed, return unknown status and message
     $message = "Could not get expiration date"
     $statistic = -1
     $exitcode = 4 #Unknown
    } finally {
     ## Close the session and destroy the IE object
     $ie.Quit()
     [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie)
     Remove-Variable ie
    }
    
    # Output message and statistic for Solarwinds, exit with exit code for Solarwinds
    Write-Host "Message: $message"
    Write-Host "Statistic: $statistic"
    exit $exitcode
Children
No Data