Report to show currently running tasks.

book

Article ID: 171824

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server)

Issue/Introduction

While troubleshooting performance issues or problems with tasks being delayed or not starting/running correctly, it may be helpful to view the currently running tasks. The following SQL query will show the currently running task reports. There is also an attached XML that can be imported as a report.

 

Resolution

declare @taskType as nvarchar (10)
 set @taskType = '%taskType%'
 SELECT 
 i.Guid AS '_ItemGuid'
 ,'Task Name' = coalesce(i.Name, '[Data not available]')
 ,tiis.name as "Run Instance Name"
 ,tiis.ExecutedBy as "Executed By"
 ,'Start Time' = coalesce (CAST(s.StartTime AS VARCHAR), '[Data has been Purged]')
 ,'Target Device' = coalesce (vci.Name, '[Could not retrieve]')
 ,'InstanceType' = 
 case ti.[InstanceType]
 when 0 then 'Server Task'
 else 'Client Task'
 end
 ,'Status' =
 CASE CAST(tis.[InstanceStatus] AS varchar)
 WHEN '1' THEN 'Running'
 WHEN '2' THEN 'Completed'
 WHEN '3' THEN 'Failed'
 WHEN '4' THEN 'Stop Requested'
 END
 from [TaskInstances] ti 
 left outer join [TaskInstancesStarted] s on s.[TaskInstanceGuid] = ti.[TaskInstanceGuid] 
 left outer join [TaskInstanceStatus] tis on tis.[TaskInstanceGuid] = ti.[TaskInstanceGuid] 
 left outer join [TaskInstanceResults] tir on tir.[TaskInstanceGuid] = ti.[TaskInstanceGuid] 
 --left outer join [TaskInstanceExecutionInfo] tiei on tiei.[TaskInstanceGuid] = ti.[TaskInstanceGuid]
 left outer join [TaskInstanceSummaries] tiis on tiis.TaskInstanceGuid = ti.TaskInstanceGuid
 LEFT OUTER JOIN vRM_Computer_Item vci ON vci.Guid = ti.ResourceGuid
 LEFT JOIN ItemVersions iv ON iv.VersionGuid = ti.TaskVersionGuid
 LEFT JOIN Item i ON i.Guid = iv.ItemGuid
 WHERE (tis.InstanceStatus = 1 OR tis.InstanceStatus = 4)
 AND ti.InstanceType like @taskType
 ORDER BY [InstanceType] DESC, [Target Device] DESC, tiis.[StartTime] DESC

Attachments

Currently Running Known Tasks.xml get_app