rbanke

Application Stability - SolarWindsMSP

Oct 31st, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Application Stability Check v1.01 - SolarWindsMSP friendly.
  2. # Created by Rich Banke, Banke IT Consulting
  3. # www.bankeit.com
  4. #
  5. # Checks the Application event log for events related to application hanging or crashing.
  6. # By default this script will check for 5 or more events 1000,1001,1002 in the past 12 hours.
  7. #
  8. # These values may be overridden with the following command line parameters.
  9. # Errors before failing: -errLimit <number>
  10. # Numbers of hours to check: -timeLimit <number>
  11. # Events to monitor: -events <number1>,<number2>,<number3>, etc
  12.  
  13.  
  14. param([Int32]$errLimit = 3, [Int32]$timeLimit = 12, [int32[]]$events = (1000,1001,1002))
  15.  
  16. $timeLimit = $timeLimit * -1
  17. $errCount = 0
  18.  
  19. $logResult = Get-EventLog Application -After (Get-Date).AddHours($timeLimit) -EntryType Error | Where-Object { $events -contains $_.EventID} |Sort InstanceID
  20. $errCount = $logResult.count
  21.  
  22. $tableFormat = @{Expression={$_.InstanceID};Label="Event ID";},@{Expression={$_.ReplacementStrings};Label="Application";}
  23.  
  24. IF($errCount -ge $errLimit) {
  25.     Write-Host "Apps have misbehaved" $errCount "times"
  26.     $logResult | Format-Table $tableFormat
  27.     Exit 1001
  28. }
  29.  
  30. Write-Host "No Misbehaving Apps"
  31. Exit 0
Add Comment
Please, Sign In to add comment