Skip to content

Commit bc2b135

Browse files
committed
#884 - adding VLF.
1 parent f4ae5db commit bc2b135

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

checks/Databasev5.Tests.ps1

+10
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,14 @@ Describe "Auto Shrink" -Tag AutoShrink, High, Database -ForEach $InstancesToTest
119119
$psitem.AutoShrink | Should -Be $psitem.ConfigValues.autoshrink -Because "Shrinking databases causes fragmentation and performance issues"
120120
}
121121
}
122+
}
123+
124+
Describe "Virtual Log Files" -Tag VirtualLogFile, Medium, Database -ForEach $InstancesToTest {
125+
$skip = Get-DbcConfigValue skip.database.vlf
126+
127+
Context "Testing Database VLFs on <_.Name>" {
128+
It "Database <_.Name> VLF count should be less than <_.ConfigValues.maxvlf> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.vlfexclude -notcontains $PsItem.Name } } {
129+
$psitem.VLF | Should -BeLessThan $psitem.ConfigValues.maxvlf -Because "Too many VLFs can impact performance and slow down backup/restore"
130+
}
131+
}
122132
}

internal/configurations/configuration.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ Set-PSFConfig -Module dbachecks -Name policy.build.behind -Value $null -Initiali
232232
Set-PSFConfig -Module dbachecks -Name policy.asymmetrickeysize.excludedb -Value @('master', 'msdb', 'tempdb') -Initialize -Description "Databases to exclude from asymmetric key size checks"
233233
Set-PSFConfig -Module dbachecks -Name policy.autoclose.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks"
234234
Set-PSFConfig -Module dbachecks -Name policy.autoshrink.excludedb -Value @() -Initialize -Description "Databases to exclude from autoclose key size checks"
235+
Set-PSFConfig -Module dbachecks -Name policy.vlf.excludedb -Value @('master', 'msdb', 'tempdb', 'model') -Initialize -Description "Databases to exclude from asymmetric key size checks"
235236

236237

237238

@@ -258,6 +259,7 @@ Set-PSFConfig -Module dbachecks -Name skip.database.invaliddatabaseowner -Valida
258259
Set-PSFConfig -Module dbachecks -Name skip.database.databasecollation -Validation bool -Value $false -Initialize -Description "Skip the database collation test"
259260
Set-PSFConfig -Module dbachecks -Name skip.database.suspectpage -Validation bool -Value $false -Initialize -Description "Skip the suspect pages test"
260261
Set-PSFConfig -Module dbachecks -Name skip.database.autoclose -Validation bool -Value $false -Initialize -Description "Skip the autoclose test"
262+
Set-PSFConfig -Module dbachecks -Name skip.database.vlf -Validation bool -Value $false -Initialize -Description "Skip the virtual log file test"
261263

262264

263265
Set-PSFConfig -Module dbachecks -Name skip.logshiptesting -Validation bool -Value $false -Initialize -Description "Skip the logshipping test"

internal/functions/Get-AllDatabaseInfo.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ function Get-AllDatabaseInfo {
8787
$suspectPage = $true
8888
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'suspectpageexclude' -Value (Get-DbcConfigValue policy.suspectpage.excludedb)
8989
}
90+
'VirtualLogFile' {
91+
$vlf = $true
92+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'maxvlf' -Value (Get-DbcConfigValue policy.database.maxvlf)
93+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'vlfexclude' -Value (Get-DbcConfigValue policy.vlf.excludedb)
94+
}
9095

9196
Default { }
9297
}
@@ -110,6 +115,7 @@ function Get-AllDatabaseInfo {
110115
#AsymmetricKeySize = if ($asymmetrickey) { $psitem.AsymmetricKeys.KeyLength } # doing this I got $null if there wasn't a key
111116
AutoClose = if ($autoclose) { $psitem.AutoClose}
112117
AutoShrink = if ($autoshrink) { $psitem.AutoShrink}
118+
VLF = if ($vlf) { ($psitem.Query("DBCC LOGINFO") | Measure-Object).Count }
113119
}
114120
}
115121
}

0 commit comments

Comments
 (0)