Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion SQLTrace/SQLTrace.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ SQLErrorLog = Yes # Line up SQL errors with other traces
SQLXEventLog = No # These are large; do not collect unless you suspect a SQL Health issue
DeleteOldFiles = No # This triggers the switch to delete old files depending on configuration of MinFiles and MinMinutes
MinFiles = 20 # Only delete files beyond this limit that are more than MinMinutes old
MinMinutes = 60 # Only delete files older than this number of minutes (LastWriteTime) has elapsed
MinMinutes = 60 # Only delete files older than this number of minutes (LastWriteTime) has elapsed
SQLCheck = Yes # Run SQLCheck if it's in the SQLTrace.ps1 folder and redirect the output to the log folder
SQLCheckPath = .\ # SQLCheck.exe location - defaults to the current folder
31 changes: 30 additions & 1 deletion SQLTrace/SQLTrace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ LogRaw "
/_______ /\_____\ \_/|_______ \|____| |__| (____ / \___ >\___ >
\/ \__> \/ \/ \/ \/

SQLTrace.ps1 version 1.0.0217.0
SQLTrace.ps1 version 1.0.0234.0
by the Microsoft SQL Server Networking Team
"

Expand Down Expand Up @@ -177,6 +177,8 @@ Function ReadINIFile
DeleteOldFiles = "No"
MinFiles = "20"
MinMinutes = "30"
SQLCheck = "Yes"
SQLCheckPath = ".\" # default to current folder
}

$fileName = $INIFile
Expand Down Expand Up @@ -232,6 +234,8 @@ Function ReadINIFile
"DeleteOldFiles" { $global:INISettings.DeleteOldFiles = $value }
"MinFiles" { $global:INISettings.MinFiles = $value }
"MinMinutes" { $global:INISettings.MinMinutes = $value }
"SQLCheck" { $global:INISettings.SQLCheck = $value }
"SQLCheckPath" { $global:INISettings.SQLCheckPath = $value }
default { "Unknown keyword $keyWord in line: $l" }
}
}
Expand Down Expand Up @@ -269,6 +273,8 @@ Function DisplayINIValues
LogInfo "DeleteOldFiles $($global:INISettings.DeleteOldFiles)"
LogInfo "MinFiles $($global:INISettings.MinFiles)"
LogInfo "MinMinutes $($global:INISettings.MinMinutes)"
LogInfo "SQLCheck $($global:INISettings.SQLCheck)"
LogInfo "SQLCheckPath $($global:INISettings.SQLCheckPath)"
}

function RegisterEventLog
Expand Down Expand Up @@ -406,6 +412,29 @@ Function StartTraces
FlushExistingTraces
FlushCaches

# Run SQLCheck

if($global:INISettings.SQLCheck -eq "Yes")
{
if((Test-Path "$($global:INISettings.SQLCheckPath)SQLCheck.exe" -PathType Leaf) -eq $false)
{
LogWarning "SQLCheck not found at the following location: $($global:INISettings.SQLCheckPath)SQLCheck.exe"
}
else
{
LogInfo "Starting SQLCheck."
$cmd = (get-item "$($global:INISettings.SQLCheckPath)SQLCheck.exe").FullName # absolute path to SQLCheck, e.g. .\sqlcheck.exe -> c:\msdata\sqlcheck.exe
Push-Location "$($global:LogFolderName)" # change to the log folder and preserve the path
$result = invoke-expression $cmd # log is written to the current [log folder] location
LogInfo "SQLCheck: $result"
Pop-Location # return to the last folder before the Push-Location
}
}
else
{
LogInfo "SQLCheck not run."
}

tasklist > "$($global:LogFolderName)\TasklistAtStart.txt"
netstat -abon > "$($global:LogFolderName)\NetStatAtStart.txt"
ipconfig -all > "$($global:LogFolderName)\IPCONFIG.txt"
Expand Down