Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider only getting ERRORLOG files below a certain size and for the remaining large files get first and last 500 lines or so #174

Closed
PiJoCoder opened this issue Jun 15, 2022 · 1 comment · Fixed by #210
Assignees
Labels
enhancement wave 1 - closed consider this issue for next wave of fixes

Comments

@PiJoCoder
Copy link
Collaborator

PiJoCoder commented Jun 15, 2022

Do you want to request a feature or report a bug?
Feature - reduce the collection of unnecessary ERRORLOG info by PSSDIAG.
We can set them at 1 GB

What is the current behavior?
We currently get entire files even if they are 2 MB or 100 GB is size

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem **

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?
All versions

Currenly geting errorlogs is re-written into a PowerShell script. We could consider adding logic in the future to only copy files of certain size.

Adding some pseudocode

 Get-ChildItem  -File | Where-Object {($_.Length -lt 1073741824) -and ($_.Length -gt 0)} | Copy-Item....

And for files that are larger files (prototype)

$errorlog_path  = "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log"
$outpu_path = "C:\temp\OutputFolder"

$errorlog_gt_1gb =  (Get-ChildItem  -Path $errorlog_path  -File -Filter "ERRORLOG*" | Where-Object {($_.Length -ge 1073741824) -and ($_.Length -gt 0)} | Select-Object Name).Name


$errorlog_gt_1gb 

foreach ($filename in $errorlog_gt_1gb)
{
  Write-Host ($outpu_path + "\" + $filename+"_Head_and_Tail_Only")
  Get-Content $filename -TotalCount 300  | Set-Content -Path ($outpu_path + "\" + $filename+"_Head_and_Tail_Only") 
  Write-Host "*************************************************"
  Add-Content -Value "`n   <<... middle part of file not captured because the file is too large (>1 GB) ... >>`n" -Path ($outpu_path + "\" + $filename+"_Head_and_Tail_Only") 
  Get-Content $filename -Tail 300 | Add-Content -Path ($outpu_path + "\" + $filename+"_Head_and_Tail_Only")
}
@PiJoCoder PiJoCoder added the wave 2 consider this issue for next wave of fixes label Jun 15, 2022
@PiJoCoder PiJoCoder changed the title Consider only getting ERRORLOG files below a certain size and for the remaining large files get first and last 100 lines or so Consider only getting ERRORLOG files below a certain size and for the remaining large files get first and last 300 lines or so Oct 26, 2022
@Peter-Msft
Copy link
Contributor

PR created: #206

@PiJoCoder PiJoCoder changed the title Consider only getting ERRORLOG files below a certain size and for the remaining large files get first and last 300 lines or so Consider only getting ERRORLOG files below a certain size and for the remaining large files get first and last 500 lines or so Nov 1, 2022
PiJoCoder added a commit that referenced this issue Nov 1, 2022
per discussion with Peter-MSFT

Co-Authored-By: Peter-Msft <54499324+peter-msft@users.noreply.github.com>
@PiJoCoder PiJoCoder added enhancement wave 1 - closed consider this issue for next wave of fixes and removed wave 2 consider this issue for next wave of fixes labels Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement wave 1 - closed consider this issue for next wave of fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants