Skip to content

Commit

Permalink
so that #887 has some checks done
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Aug 23, 2023
1 parent 2f25a0f commit 069750e
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions source/internal/functions/Get-AllAgentInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function Get-AllAgentInfo {
}
'AgentServiceAccount' {
if (($Instance.VersionMajor -ge 14) -or $IsLinux -or $Instance.HostPlatform -eq 'Linux') {
$Agent = @($Instance.Query("SELECT status_desc, startup_type_desc FROM sys.dm_server_services") | Where-Object servicename -Like '*Agent*').ForEach{
$Agent = @($Instance.Query("SELECT status_desc, startup_type_desc, servicename FROM sys.dm_server_services") | Where-Object servicename -Like '*Agent*').ForEach{
[PSCustomObject]@{
State = $PSItem.status_desc
StartMode = $PSItem.startup_type_desc
Expand Down Expand Up @@ -163,10 +163,10 @@ function Get-AllAgentInfo {

$JobsFailed = ($Instance.JobServer.Jobs | Where-Object { $_.IsEnabled -and ($_.LastRunDate -gt $startdate) }).ForEach{
[PSCustomObject]@{
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedOutcome = $ConfigValues.FailedJob
LastRunOutcome = $PSItem.LastRunOutcome
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedOutcome = $ConfigValues.FailedJob
LastRunOutcome = $PSItem.LastRunOutcome
}
}
}
Expand All @@ -180,10 +180,10 @@ function Get-AllAgentInfo {

$JobOwner = $Instance.JobServer.Jobs.ForEach{
[PSCustomObject]@{
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedJobOwnerName = $ConfigValues.TargetJobOwner #$PSItem
ActualJobOwnerName = $PSItem.OwnerLoginName
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedJobOwnerName = $ConfigValues.TargetJobOwner #$PSItem
ActualJobOwnerName = $PSItem.OwnerLoginName
}
}
}
Expand All @@ -197,10 +197,10 @@ function Get-AllAgentInfo {

$InvalidJobOwner = $Instance.JobServer.Jobs.ForEach{
[PSCustomObject]@{
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedJobOwnerName = $ConfigValues.InvalidJobOwner
ActualJobOwnerName = $PSItem.OwnerLoginName
InstanceName = $Instance.Name
JobName = $PSItem.Name
ExpectedJobOwnerName = $ConfigValues.InvalidJobOwner
ActualJobOwnerName = $PSItem.OwnerLoginName
}
}

Expand Down Expand Up @@ -303,13 +303,13 @@ function Get-AllAgentInfo {

$LongRunningJobs = $($runningjobs | Where-Object { $_.AvgSec -ne 0 }).ForEach{
[PSCustomObject]@{
InstanceName = $Instance.Name
JobName = $PSItem.JobName
RunningSeconds = $PSItem.RunningSeconds
Average = $PSItem.AvgSec
Diff = $PSItem.Diff
ExpectedLongRunningJobPercentage = $ConfigValues.LongRunningJob
ActualLongRunningJobPercentage = [math]::Round($PSItem.Diff / $PSItem.AvgSec * 100)
InstanceName = $Instance.Name
JobName = $PSItem.JobName
RunningSeconds = $PSItem.RunningSeconds
Average = $PSItem.AvgSec
Diff = $PSItem.Diff
ExpectedLongRunningJobPercentage = $ConfigValues.LongRunningJob
ActualLongRunningJobPercentage = [math]::Round($PSItem.Diff / $PSItem.AvgSec * 100)
}
}
}
Expand Down Expand Up @@ -367,12 +367,12 @@ function Get-AllAgentInfo {

$LastJobRuns = $($lastagentjobruns | Where-Object { $_.AvgSec -ne 0 }).ForEach{
[PSCustomObject]@{
InstanceName = $Instance.Name
JobName = $PSItem.JobName
Duration = $PSItem.Duration
Average = $PSItem.AvgSec
ExpectedRunningJobPercentage = $ConfigValues.LastJobRuns
ActualRunningJobPercentage = [math]::Round($PSItem.Diff / $PSItem.AvgSec * 100)
InstanceName = $Instance.Name
JobName = $PSItem.JobName
Duration = $PSItem.Duration
Average = $PSItem.AvgSec
ExpectedRunningJobPercentage = $ConfigValues.LastJobRuns
ActualRunningJobPercentage = [math]::Round($PSItem.Diff / $PSItem.AvgSec * 100)
}
}
}
Expand Down

0 comments on commit 069750e

Please sign in to comment.