長期執行作業

Microsoft.SQLServer.2012.Agent.LongRunningJobs (UnitMonitor)

此監視器會檢查長期執行的 SQL Agent 作業。

Knowledge Base article:

摘要

此監視器會檢查長期執行的 SQL Agent 作業。如有作業長時間持續執行超過設定臨界值,將產生警告或錯誤警示。

原因

由於有 SQL Server Agent 作業執行的時間已超過定義臨界值,而導致狀況不良狀態。這可能表示該作業發生問題。

SQL Server Agent 負責執行排定在特定時間或間隔執行的 SQL Server 工作,以及偵測系統管理員已定義動作的特定狀況,如透過呼叫或電子郵件向某人發出警示,或解決該狀況的工作。SQL Server Agent 也用於執行系統管理員定義的複寫工作。

為判定造成警告或錯誤狀態的作業,請檢視狀態變更或警示的內容資料。

解決方式

檢查 SQL Server Management Studio 以判定執行中的作業為何。如果這些作業執行的時間過長,請進行調查以找出原因。

使用 sp_help_jobactivity 查看目前執行中作業的相關資訊。

或者,如果希望部分代理程式作業長期執行:

Element properties:

TargetMicrosoft.SQLServer.2012.Agent
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2012.AgentLongRunningJobsProvider
RemotableTrue
AccessibilityPublic
Alert Message
長期執行作業
電腦 {0} 上的 SQL 執行個體 {1} 中有長期執行的代理程式作業。這可能表示一個或多個作業發生問題。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2012.Agent.LongRunningJobs" Accessibility="Public" Enabled="false" Target="SQL2012Core!Microsoft.SQLServer.2012.Agent" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2012.AgentLongRunningJobsProvider" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.Agent.LongRunningJobs.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="UnderThreshold1" MonitorTypeStateID="UnderThreshold1" HealthState="Success"/>
<OperationalState ID="OverThreshold1UnderThreshold2" MonitorTypeStateID="OverThreshold1UnderThreshold2" HealthState="Warning"/>
<OperationalState ID="OverThreshold2" MonitorTypeStateID="OverThreshold2" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>600</IntervalSeconds>
<SyncTime/>
<ConnectionString>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<Threshold1>60</Threshold1>
<Threshold2>120</Threshold2>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>