Skip to content

Commit

Permalink
so that we cna check max memory #882
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Mar 28, 2023
1 parent 1a625b8 commit 196cad0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,15 @@ Describe "Linked Servers" -Tags LinkedServerConnection, Connectivity, Medium, In
}
}

Describe "Max Memory" -Tag MaxMemory, High, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.maxmemory' }).Value
Context "Testing Max Memory on <_.Name>" {
It "Max Memory setting should be correct on <_.Name>" -Skip:$skip {
$Psitem.MaxMemory.MaxValue | Should -BeLessThan $Psitem.MaxMemory.RecommendedValue -Because 'You do not want to exhaust server memory'
}
}
}

<#
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name
Expand Down
1 change: 1 addition & 0 deletions source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.tempdb -Validation bool -Val
Set-PSFConfig -Module dbachecks -Name skip.instance.BackupPathAccess -Validation bool -Value $false -Initialize -Description "Skip the check for the backup path access check"
Set-PSFConfig -Module dbachecks -Name skip.instance.networklatency -Validation bool -Value $false -Initialize -Description "Skip the check for network latency"
Set-PSFConfig -Module dbachecks -Name skip.instance.linkedserverconnection -Validation bool -Value $false -Initialize -Description "Skip the check for linked server connection"
Set-PSFConfig -Module dbachecks -Name skip.instance.maxmemory -Validation bool -Value $false -Initialize -Description "Skip the check for max memory"



Expand Down
22 changes: 22 additions & 0 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,27 @@ function NewGet-AllInstanceInfo {
$LinkedServerResults = Test-DbaLinkedServerConnection -SqlInstance $Instance
}

'MaxMemory' {
if ($isLinux -or $isMacOS) {
$totalMemory = $Instance.PhysicalMemory
# Some servers under-report by 1.
if (($totalMemory % 1024) -ne 0) {
$totalMemory = $totalMemory + 1
}
$MaxMemory = [PSCustomObject]@{
MaxValue = $totalMemory
RecommendedValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379
# because we added 379 before and I have zero idea why
}
} else {
$MemoryValues = Test-DbaMaxMemory -SqlInstance $Instance
$MaxMemory = [PSCustomObject]@{
MaxValue = $MemoryValues.MaxValue
RecommendedValue = $MemoryValues.RecommendedValue
}
}
}

Default { }
}

Expand Down Expand Up @@ -422,6 +443,7 @@ function NewGet-AllInstanceInfo {
Result = 'None'
}
}
MaxMemory = $MaxMemory
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit 196cad0

Please sign in to comment.