I do this in SQL like @markdamen did. I check for any reports longer than 10 minutes every 5 minutes with certain things and users excluded. The second query just checks for MRP Regen hanging with no activity.
If (select count(*)
from [EpicorProduction].[Ice].[SysTask]
where EndedOn is null and TaskType='report'
and TaskDescription not like 'BOM Listing%' and TaskDescription not like 'material%' and TaskDescription not like 'Inspection Pending%'
and TaskDescription not like 'AP Invoice Balance%' and TaskDescription not like '%Ledger%' and TaskDescription not like '%Method Master%'
and TaskDescription not like 'Inventory Usage%' and TaskDescription not like 'Inventory WIP%' and TaskDescription not like 'Open DMR%'
and TaskDescription not like 'Stock Status%' and TaskDescription not like 'Work In Process%' and TaskDescription not like '%PartWhereUsed%'
and SubmitUser not in ('vluk01','jgil01','nkha01','syem01','acal01','acct01','nkoc01') and TaskStatus <> 'Error' and TaskStatus <> 'CANCELED'
and (DateDiff(minute, [StartedOn], GetutcDate()) > 10)) >= 1
begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'admin',
@recipients = 'me@domain.com ;usupport@domain.com',
@subject = 'Epicor Report over 10 minutes - Check Display All Tasks and then cancel in Epicor System Monitor',
@query = 'select SubmitUser,UserPIDInfo,TaskDescription, StartedOn
from [EpicorProduction].[Ice].[SysTask]
where EndedOn is null and TaskType=''report''
and TaskDescription not like ''BOM Listing%'' and TaskDescription not like ''material%'' and TaskDescription not like ''Inspection Pending%''
and TaskDescription not like ''AP Invoice Balance%'' and TaskDescription not like ''%Ledger%'' and TaskDescription not like ''%Method Master%''
and TaskDescription not like ''Inventory Usage%'' and TaskDescription not like ''Inventory WIP%'' and TaskDescription not like ''Open DMR%''
and TaskDescription not like ''Stock Status%'' and TaskDescription not like ''Work In Process%'' and TaskDescription not like ''%PartWhereUsed%''
and SubmitUser not in (''vluk01'',''jgil01'',''nkha01'',''syem01'',''acal01'',''acct01'',''nkoc01'') and TaskStatus <> ''Error'' and TaskStatus <> ''CANCELED''
and (DateDiff(minute, [StartedOn], GetutcDate()) > 10)'
end
MRP hung
If (select count(*)
from [EpicorProduction].[Ice].[SysTask]
where EndedOn is null and
TaskType='PROCESS'
and TaskDescription like 'Process MRP%' and TaskStatus <> 'Error' and TaskStatus <> 'CANCELED'
and DateDiff(minute, LastActivityOn, GetutcDate()) > 10 or
(DateDiff(minute, startedon, GetutcDate()) > 300 and LastActivityOn is null)) >= 1
begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'admin',
@recipients = 'me@domain.com ;usupport@domain.com',
@subject = 'Epicor - MRP hung over 10 minutes - Stop Task in System Monitor',
@query = 'select SubmitUser,UserPIDInfo,TaskDescription, StartedOn
from [EpicorProduction].[Ice].[SysTask]
where EndedOn is null and
TaskType=''PROCESS''
and TaskDescription like ''Process MRP%'' and TaskStatus <> ''Error'' and TaskStatus <> ''CANCELED''
and (DateDiff(minute, LastActivityOn, GetutcDate()) > 10 or
(DateDiff(minute, startedon, GetutcDate()) > 300 and LastActivityOn is null))
'
--@attach_query_result_as_file = 1,
--@query_attachment_filename = 'Misc Invoices.txt'
end