Skip to content

Commit

Permalink
Merge pull request #931 from dataplat/moreinstancechecks
Browse files Browse the repository at this point in the history
Moreinstancechecks
  • Loading branch information
SQLDBAWithABeard authored Mar 30, 2023
2 parents c0b12ed + 7ac5f93 commit 76accc1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
7 changes: 7 additions & 0 deletions containers/JessAndBeard.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,13 @@ The Tags are the same"
FailedChange = -12 # + or - the number of tests failed for v5
SkippedChange = 0 # + or - the number of tests skipped for v5
}
@{
Name = 'LinkedServerConnection'
RunChange = -3 # + or - the number of tests for v5
PassedChange = -3 # + or - the number of tests passed for v5
FailedChange = 0 # + or - the number of tests failed for v5
SkippedChange = 0 # + or - the number of tests skipped for v5
}
)
$runchange = 0
$passedchange = 0
Expand Down
20 changes: 10 additions & 10 deletions developing/Robs-Instance.ps1
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
$Checks = 'ErrorLogCount','TraceFlagsNotExpected','TraceFlagsExpected', 'XESessionRunningAllowed','XESessionRunning','XESessionRunningAllowed', 'XESessionExists','XESessionStopped','XpCmdShellDisabled','WhoIsActiveInstalled','CLREnabled','TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation'
$Checks = 'ErrorLogCount', 'TraceFlagsNotExpected', 'TraceFlagsExpected', 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation'

$Checks = 'XESessionRunningAllowed','XESessionRunning','XESessionRunningAllowed','XESessionExists','XESessionStopped','XpCmdShellDisabled'
$Checks = 'TraceFlagsNotExpected','TraceFlagsExpected'
$Checks = 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled'
$Checks = 'TraceFlagsNotExpected', 'TraceFlagsExpected'

Invoke-PerfAndValidateCheck -Checks $Checks
Invoke-PerfAndValidateCheck -Checks $Checks -PerfDetail

$containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks1', 'dbachecks2', 'dbachecks3'
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
$show = 'All'

$v4code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $true -Show $show -PassThru
# Run v5 checks
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose

Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health,QuickSessionStandard
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health, QuickSessionStandard

Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health ,AlwaysOn_health
Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health , AlwaysOn_health
Set-DbcConfig -Name policy.xevent.validrunningsession -Value AlwaysOn_health

$traci = Trace-Script -ScriptBlock {
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru
}
4 changes: 1 addition & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# dbachecks


<img align="right" height="300" src="https://api.star-history.com/svg?repos=dataplat/dbachecks&type=Date">

<a href="https://star-history.com/#dataplat/dbachecks&Date"><img align="right" height="300" src="https://api.star-history.com/svg?repos=dataplat/dbachecks&type=Date"></a>

[![.github/workflows/deploy-module.yml](https://github.com/dataplat/dbachecks/actions/workflows/deploy-module.yml/badge.svg?branch=main)](https://github.com/dataplat/dbachecks/actions/workflows/deploy-module.yml)
[![GitHub release badge](https://badgen.net/github/release/dataplat/dbachecks/stable?label=latest_release)](https://github.com/dataplat/dbachecks/releases/latest)
Expand Down
19 changes: 19 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,25 @@ Describe "Max Memory" -Tag MaxMemory, High, Instance -ForEach $InstancesToTest {
}
}

Describe "Orphaned Files" -Tag OrphanedFile, Low, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.orphanedfile' }).Value
Context "Testing Orphaned Files on <_.Name>" {
It "should not have orphaned files on <_.Name>" -Skip:$skip {
$Psitem.OrphanedFile.FileCount | Should -Be 0 -Because 'You dont want any orphaned files - Use Find-DbaOrphanedFile to locate them'
}
}
}

Describe "SQL and Windows names match" -Tag ServerNameMatch, Medium, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.servernamematch' }).Value
Context "Testing SQL and Windows names match on <_.Name>" {
It "should have matching names on <_.Name>" -Skip:$skip {
$Psitem.ServerNameMatch.renamerequired | Should -BeFalse -Because "SQL and Windows names should match but configured name $($Psitem.ServerNameMatch.configuredServerName) does not match $($Psitem.ServerNameMatch.netName)"
}
}
}


<#
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name
Expand Down
2 changes: 2 additions & 0 deletions source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.BackupPathAccess -Validation
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"
Set-PSFConfig -Module dbachecks -Name skip.instance.orphanedfile -Validation bool -Value $false -Initialize -Description "Skip the check for orphaned file"
Set-PSFConfig -Module dbachecks -Name skip.instance.servernamematch -Validation bool -Value $false -Initialize -Description "Skip the check for server name match"



Expand Down
22 changes: 20 additions & 2 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ function NewGet-AllInstanceInfo {
$totalMemory = $totalMemory + 1
}
$MaxMemory = [PSCustomObject]@{
MaxValue = $totalMemory
RecommendedValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379
MaxValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379
RecommendedValue = $totalMemory
# because we added 379 before and I have zero idea why
}
} else {
Expand All @@ -354,6 +354,16 @@ function NewGet-AllInstanceInfo {
}
}

OrphanedFile {
$FileCount = @(Find-DbaOrphanedFile -SqlInstance $Instance).Count
}

ServerNameMatch {
$ServerNameMatchconfiguredServerName = $Instance.Query("SELECT @@servername AS ServerName").ServerName
$ServerNameMatchnetName = $Instance.NetName
$ServerNameMatchrenamerequired = $ServerNameMatchnetName -ne $ServerNameMatchconfiguredServerName
}

Default { }
}

Expand Down Expand Up @@ -444,6 +454,14 @@ function NewGet-AllInstanceInfo {
}
}
MaxMemory = $MaxMemory
OrphanedFile = [pscustomobject]@{
FileCount = $FileCount
}
ServerNameMatch = [pscustomobject]@{
configuredServerName = $ServerNameMatchconfiguredServerName
netName = $ServerNameMatchnetName
renamerequired = $ServerNameMatchrenamerequired
}
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit 76accc1

Please sign in to comment.