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

Percent log used check #831

Merged
merged 3 commits into from
Apr 7, 2021
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
24 changes: 24 additions & 0 deletions checks/Database.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,30 @@ $ExcludedDatabases += $ExcludeDatabase
}
}


Describe "Log File percent used" -Tags LogfilePercentUsed, Medium, $filename {
$LogFilePercentage = Get-DbcConfigValue policy.database.logfilepercentused
if ($NotContactable -contains $psitem) {
Context "Testing Log File percent used for $psitem" {
It "Can't Connect to $Psitem" {
$true | Should -BeFalse -Because "The instance should be available to be connected to!"
}
}
}
else {
Context "Testing Log File percent used for $psitem" {
$InstanceSMO.Databases.Where{ $(if ($Database) { $PsItem.Name -in $Database }else { $ExcludedDatabases -notcontains $PsItem.Name }) -and ($Psitem.IsAccessible -eq $true) }.ForEach{
$LogFiles = Get-DbaDbSpace -SqlInstance $psitem.Parent.Name -Database $psitem.Name | Where-Object {$_.FileType -eq "LOG"}
$DatabaseName = $psitem.Name
$CurrentLogFilePercentage = ($LogFiles | Measure-Object -Property PercentUsed -Maximum).Maximum
It "Database $DatabaseName Should have apercentage used lower than $LogFilePercentage% on $($psitem.Parent.Name)" {
$CurrentLogFilePercentage | Should -BeLessThan $LogFilePercentage -Because "Check backup strategy, open transactions, CDC, Replication and HADR solutions "
}
}
}
}
}

Describe "Virtual Log Files" -Tags VirtualLogFile, Medium, $filename {
$vlfmax = Get-DbcConfigValue policy.database.maxvlf
if ($NotContactable -contains $psitem) {
Expand Down
4 changes: 4 additions & 0 deletions internal/configurations/DbcCheckDescriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
"UniqueTag": "LogfileSize",
"Description": "Tests that the database log files are less than the specified percentage of the specified comparison (maximum size or average - default is average) of the data file size (default 100)"
},
{
"UniqueTag": "LogfilePercentUsed",
"Description": "Tests that the database percent log file used is less than the specified percentage (default 75)"
},
{
"UniqueTag": "FutureFileGrowth",
"Description": "Tests if a database (except for those specified to be skipped explicitly) has free space less than the specified percentage (default 20)"
Expand Down
1 change: 1 addition & 0 deletions internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Set-PSFConfig -Module dbachecks -Name policy.database.filegrowthdaystocheck -Val
Set-PSFConfig -Module dbachecks -Name policy.database.trustworthyexcludedb -Value @() -Initialize -Description "A List of databases that we do not want to check for Trustworthy being on"
Set-PSFConfig -Module dbachecks -Name policy.database.duplicateindexexcludedb -Value @('msdb','ReportServer','ReportServerTempDB') -Initialize -Description "A List of databases we do not want to check for Duplicate Indexes"
Set-PSFConfig -Module dbachecks -Name policy.database.clrassembliessafeexcludedb -Value @() -Initialize -Description " A List of database what we do not want to check for SAFE CLR Assemblies"
Set-PSFConfig -Module dbachecks -Name policy.database.logfilepercentused -Value 75 -Initialize -Description " The % log used we should stay below"

# Policy for Ola Hallengren Maintenance Solution
Set-PSFConfig -Module dbachecks -name policy.ola.installed -Validation bool -Value $true -Initialize -Description "Checks to see if Ola Hallengren solution is installed"
Expand Down