長期執行作業

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

此監視器會查看是否有長時間執行的 SQL Agent 作業。
請注意,所有版本的 SQL Server Express 都不支援 SQL Server Agent Windows 服務; 所以沒有探索到任何適當的物件。注意: 預設會停用此監視器。必要時請使用覆寫加以啟用。

Knowledge Base article:

摘要

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

原因

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

SQL Server Agent 負責執行排定在特定時間或間隔發生的 SQL Server 工作,以及偵測管理員定義為動作的特定情況 (例如透過呼叫器或電子郵件警示某人),或是將可解決各種情況的作業。SQL Server Agent 也可用以執行管理員所定義的複寫作業。

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

解決方式

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

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

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

可覆寫的參數

名稱

描述

預設值

警示優先程式

定義警示優先順序。

一般

警示嚴重性

定義警示嚴重性。

MatchMonitorHealth

重大臨界值 (分鐘)

若此值超過這個臨界值,此監視器會將狀態變更為重大。若在這個臨界值與警告臨界值 (含) 之間,此監視器會是警告狀態。

120

已啟用

啟用或停用該工作流程。

產生警示

定義工作流程是否會產生警示。

間隔 (秒)

執行工作流程的週期性時間間隔 (秒)。

600

同步處理時間

使用 24 小時制指定的同步處理時間。將會忽略。

 

逾時 (秒)

指定允許工作流程在關閉且標示為失敗之前執行的時間。

300

警告臨界值 (分鐘)

警告臨界值。超出此臨界值會導致監視器變更為至少是警告狀態。

60

Element properties:

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

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2016.Agent.LongRunningJobs" Accessibility="Public" Enabled="false" Target="SQL2016Core!Microsoft.SQLServer.2016.Agent" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2016.AgentLongRunningJobsProvider" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2016.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="SQL2016Core!Microsoft.SQLServer.2016.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="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/ConnectionString$</ConnectionString>
<Threshold1>60</Threshold1>
<Threshold2>120</Threshold2>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>