Skip to content

Commit 76accc1

Browse files
Merge pull request #931 from dataplat/moreinstancechecks
Moreinstancechecks
2 parents c0b12ed + 7ac5f93 commit 76accc1

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

containers/JessAndBeard.psm1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,13 @@ The Tags are the same"
23262326
FailedChange = -12 # + or - the number of tests failed for v5
23272327
SkippedChange = 0 # + or - the number of tests skipped for v5
23282328
}
2329+
@{
2330+
Name = 'LinkedServerConnection'
2331+
RunChange = -3 # + or - the number of tests for v5
2332+
PassedChange = -3 # + or - the number of tests passed for v5
2333+
FailedChange = 0 # + or - the number of tests failed for v5
2334+
SkippedChange = 0 # + or - the number of tests skipped for v5
2335+
}
23292336
)
23302337
$runchange = 0
23312338
$passedchange = 0

developing/Robs-Instance.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
$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'
1+
$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'
22

3-
$Checks = 'XESessionRunningAllowed','XESessionRunning','XESessionRunningAllowed','XESessionExists','XESessionStopped','XpCmdShellDisabled'
4-
$Checks = 'TraceFlagsNotExpected','TraceFlagsExpected'
3+
$Checks = 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled'
4+
$Checks = 'TraceFlagsNotExpected', 'TraceFlagsExpected'
55

66
Invoke-PerfAndValidateCheck -Checks $Checks
77
Invoke-PerfAndValidateCheck -Checks $Checks -PerfDetail
8-
8+
$containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks1', 'dbachecks2', 'dbachecks3'
99
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
1010
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
1111
$show = 'All'
1212

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

17-
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health
18-
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health
19-
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health,QuickSessionStandard
17+
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health
18+
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health
19+
Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health, QuickSessionStandard
2020

21-
Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health ,AlwaysOn_health
21+
Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health , AlwaysOn_health
2222
Set-DbcConfig -Name policy.xevent.validrunningsession -Value AlwaysOn_health
2323

2424
$traci = Trace-Script -ScriptBlock {
25-
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru
25+
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru
2626
}

readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# dbachecks
22

3-
4-
<img align="right" height="300" src="https://api.star-history.com/svg?repos=dataplat/dbachecks&type=Date">
5-
3+
<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>
64

75
[![.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)
86
[![GitHub release badge](https://badgen.net/github/release/dataplat/dbachecks/stable?label=latest_release)](https://github.com/dataplat/dbachecks/releases/latest)

source/checks/Instancev5.Tests.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,25 @@ Describe "Max Memory" -Tag MaxMemory, High, Instance -ForEach $InstancesToTest {
391391
}
392392
}
393393

394+
Describe "Orphaned Files" -Tag OrphanedFile, Low, Instance -ForEach $InstancesToTest {
395+
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.orphanedfile' }).Value
396+
Context "Testing Orphaned Files on <_.Name>" {
397+
It "should not have orphaned files on <_.Name>" -Skip:$skip {
398+
$Psitem.OrphanedFile.FileCount | Should -Be 0 -Because 'You dont want any orphaned files - Use Find-DbaOrphanedFile to locate them'
399+
}
400+
}
401+
}
402+
403+
Describe "SQL and Windows names match" -Tag ServerNameMatch, Medium, Instance -ForEach $InstancesToTest {
404+
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.servernamematch' }).Value
405+
Context "Testing SQL and Windows names match on <_.Name>" {
406+
It "should have matching names on <_.Name>" -Skip:$skip {
407+
$Psitem.ServerNameMatch.renamerequired | Should -BeFalse -Because "SQL and Windows names should match but configured name $($Psitem.ServerNameMatch.configuredServerName) does not match $($Psitem.ServerNameMatch.netName)"
408+
}
409+
}
410+
}
411+
412+
394413
<#
395414
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
396415
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name

source/internal/configurations/configuration.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.BackupPathAccess -Validation
283283
Set-PSFConfig -Module dbachecks -Name skip.instance.networklatency -Validation bool -Value $false -Initialize -Description "Skip the check for network latency"
284284
Set-PSFConfig -Module dbachecks -Name skip.instance.linkedserverconnection -Validation bool -Value $false -Initialize -Description "Skip the check for linked server connection"
285285
Set-PSFConfig -Module dbachecks -Name skip.instance.maxmemory -Validation bool -Value $false -Initialize -Description "Skip the check for max memory"
286+
Set-PSFConfig -Module dbachecks -Name skip.instance.orphanedfile -Validation bool -Value $false -Initialize -Description "Skip the check for orphaned file"
287+
Set-PSFConfig -Module dbachecks -Name skip.instance.servernamematch -Validation bool -Value $false -Initialize -Description "Skip the check for server name match"
286288

287289

288290

source/internal/functions/NewGet-AllInstanceInfo.ps1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ function NewGet-AllInstanceInfo {
341341
$totalMemory = $totalMemory + 1
342342
}
343343
$MaxMemory = [PSCustomObject]@{
344-
MaxValue = $totalMemory
345-
RecommendedValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379
344+
MaxValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379
345+
RecommendedValue = $totalMemory
346346
# because we added 379 before and I have zero idea why
347347
}
348348
} else {
@@ -354,6 +354,16 @@ function NewGet-AllInstanceInfo {
354354
}
355355
}
356356

357+
OrphanedFile {
358+
$FileCount = @(Find-DbaOrphanedFile -SqlInstance $Instance).Count
359+
}
360+
361+
ServerNameMatch {
362+
$ServerNameMatchconfiguredServerName = $Instance.Query("SELECT @@servername AS ServerName").ServerName
363+
$ServerNameMatchnetName = $Instance.NetName
364+
$ServerNameMatchrenamerequired = $ServerNameMatchnetName -ne $ServerNameMatchconfiguredServerName
365+
}
366+
357367
Default { }
358368
}
359369

@@ -444,6 +454,14 @@ function NewGet-AllInstanceInfo {
444454
}
445455
}
446456
MaxMemory = $MaxMemory
457+
OrphanedFile = [pscustomobject]@{
458+
FileCount = $FileCount
459+
}
460+
ServerNameMatch = [pscustomobject]@{
461+
configuredServerName = $ServerNameMatchconfiguredServerName
462+
netName = $ServerNameMatchnetName
463+
renamerequired = $ServerNameMatchrenamerequired
464+
}
447465
# TempDbConfig = [PSCustomObject]@{
448466
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
449467
# TF118EnabledRecommended = $tempDBTest[0].Recommended

0 commit comments

Comments
 (0)