Last Run Status

Microsoft.SQLServer.Windows.Monitor.AgentJob.LastRunState (UnitMonitor)

SQL Agent Job on Windows Last Run State Monitor. Monitors the last run state of an SQL Agent Job.
Note that SQL Server Agent Windows Service is not supported by any edition of SQL Server Express; there is no appropriate discovered object.

Knowledge Base article:

Summary

SQL Agent Job Last Run State Monitor. Monitors the last run state of an SQL Agent Job.

Configuration

IntervalSeconds (sec) default 600.

Overridable Parameters

Name

Description

Default Value

Alert Priority

Defines Alert Priority.

Normal

Alert Severity

Defines Alert Severity.

Warning

Enabled

Enables or disables the workflow.

Yes

Generates Alerts

Defines whether the workflow generates an Alert.

Yes

Interval (seconds)

The recurring interval of time in seconds in which to run the workflow.

600

Synchronization Time

The synchronization time specified by using a 24-hour format. May be omitted.

 

Timeout (seconds)

Specifies the time the workflow is allowed to run before being closed and marked as failed.

300

Timeout for database connection (seconds)

The workflow will fail and register an event, if it cannot access the database during the specified period.

15

Element properties:

TargetMicrosoft.SQLServer.Windows.AgentJob
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.Windows.MonitorType.AgentJob.LastRunState
RemotableTrue
AccessibilityPublic
Alert Message
MSSQL on Windows: Agent Job Last Run Failed
Last execution of the agent job "{0}" failed.
Instance name: {1}
Machine name: {2}
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.Windows.Monitor.AgentJob.LastRunState" Accessibility="Public" Enabled="true" Target="SqlDiscW!Microsoft.SQLServer.Windows.AgentJob" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.Windows.MonitorType.AgentJob.LastRunState" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.Windows.Monitor.AgentJob.LastRunState.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.AgentJob"]/Name$</AlertParameter1>
<AlertParameter2>$Target/Host/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="LastRunSucceeded" MonitorTypeStateID="LastRunSucceeded" HealthState="Success"/>
<OperationalState ID="LastRunFailed" MonitorTypeStateID="LastRunFailed" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<MachineName>$Target/Host/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</MachineName>
<InstanceName>$Target/Host/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</InstanceName>
<ConnectionString>$Target/Host/Host/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/ConnectionString$</ConnectionString>
<MonitoringType>$Target/Host/Host/Property[Type="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine"]/MonitoringType$</MonitoringType>
<JobName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.AgentJob"]/Name$</JobName>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<TimeoutSeconds>300</TimeoutSeconds>
<IntervalSeconds>600</IntervalSeconds>
<SyncTime/>
</Configuration>
</UnitMonitor>