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