ODI报错/警告/调度异常流程信息

SELECT * FROM (

select

/*流程监控:ODI问题流程最新记录【仅限调度活动的流程】*/

/*error*/

[SCHOOL] SCHOOL,--学校

业务系统 OPER_SYS,--业务系统

流程名称 PROCESS_NAME,--"调度名称/流程名称"

源对象 SRC_OBJ,--源对象

目标对象 TAG_OBJ,--目标对象

'['||LAGENT_NAME||'] '||调度周期 SCHEDULE,--调度周期

状态 SESS_STATUS,--状态

最新执行结束时间 LAST_SESS_END,--最新执行结束时间

报错信息 ERR_MESSAGE,--报错信息

to_char(SYSDATE,'yyyy-mm-dd hh24:mi:ss') TIMEFLAG

from (

select distinct

CASE WHEN xm2.PAR_I_FOLDER is not null then (SELECT XM3.FOLDER_NAME FROM ly_odi_gzk.SNP_FOLDER XM3

WHERE XM3.I_FOLDER=XM2.PAR_I_FOLDER)--三层根文件夹

when XM.PAR_I_FOLDER IS NOT NULL THEN xm2.FOLDER_NAME--两层根文件夹

ELSE XM.FOLDER_NAME END 业务系统,--一层根文件夹

jk.i_pop 接口,

SCEN.SCEN_NAME||(CASE WHEN SCEN.I_PACKAGE IS NOT NULL THEN '--'||STEP_REPORT.STEP_NAME ELSE '' END) 流程名称,

AGEN.LAGENT_NAME,

yb.table_name 源对象,

jk.table_name 目标对象,

case when agen.stat_plan = 'D' then '非活动' when agen.stat_plan = 'E' then '活动' when agen.stat_plan is null then '无调度'

else agen.stat_plan end 调度状态,

case when agen.I_PLAN_AGENT is null then '/' --无调度

when agen.R_TIME||agen.s_type='1D' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

when agen.R_TIME||agen.s_type='1S' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second

when agen.R_TIME||agen.s_type='1W' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.R_TIME||agen.s_type='1M' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN AGEN.R_TIME||AGEN.S_TYPE='1H' THEN AGEN.S_HOUR||':'||AGEN.S_MINUTE||':'||AGEN.S_SECOND||'/H'

else agen.r_dur_interval||agen.r_interval_unit||(

case when agen.s_type='S' then '('||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||')'

when agen.s_type='W' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.s_type='M' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN agen.s_type='D' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

WHEN agen.s_type='Y' then ' & '||agen.S_MONTH||'.'||agen.S_DAY||' '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/Y'

else ' & '||agen.s_type end

) end 调度周期,

'报错' 状态,

to_char(STEP_REPORT.STEP_END,'yyyy-mm-dd hh24:mm:ss') 最新执行结束时间,

to_char(CASE WHEN STEP_REPORT.ERROR_MESSAGE LIKE '%at %' THEN SUBSTR(STEP_REPORT.ERROR_MESSAGE,1,instr(STEP_REPORT.ERROR_MESSAGE,chr(9)||'at ')-2) ELSE STEP_REPORT.ERROR_MESSAGE END) 报错信息

,agen.SCEN_NAME||''||agen.SCEN_VERSION 场景

FROM (SELECT * FROM LY_ODI_GZK.SNP_STEP_REPORT A WHERE A.STEP_STATUS = 'E' AND A.SCEN_RUN_NO IN (SELECT SCEN_RUN_NO FROM (SELECT SCEN_RUN_NO,ROW_NUMBER() OVER(PARTITION BY STEP_NAME ORDER BY STEP_END DESC) RAWNUM FROM LY_ODI_GZK.SNP_STEP_REPORT) WHERE RAWNUM = 1)) STEP_REPORT

LEFT JOIN LY_ODI_GZK.SNP_POP JK ON UPPER(STEP_REPORT.STEP_NAME) =UPPER(JK.POP_NAME)

LEFT JOIN LY_ODI_GZK.SNP_TRT TRT ON UPPER(STEP_REPORT.STEP_NAME) =UPPER(TRT.TRT_NAME)

LEFT JOIN LY_ODI_GZK.SNP_FOLDER XM on COALESCE(JK.I_FOLDER,TRT.I_FOLDER) = XM.I_FOLDER

left join LY_ODI_GZK.SNP_FOLDER XM2 on XM.PAR_I_FOLDER = XM2.I_FOLDER

LEFT JOIN LY_ODI_GZK.SNP_SCEN SCEN ON STEP_REPORT.SCEN_NO = SCEN.SCEN_NO

left join LY_ODI_GZK.SNP_SOURCE_TAB YB on YB.I_DATA_SET = JK.I_POP

left join (SELECT * FROM ly_odi_gzk.SNP_PLAN_AGENT WHERE STAT_PLAN = 'E') agen on (agen.SCEN_NAME||''||agen.SCEN_VERSION) = (SCEN.SCEN_NAME||''||SCEN.SCEN_VERSION)

WHERE AGEN.STAT_PLAN = 'E' AND UPPER(AGEN.SCEN_NAME) NOT IN (SELECT UPPER(SCEN_NAME) FROM LY_ODI_GZK.SNP_SESSION WHERE SCEN_NAME IS NOT NULL AND MASTER_AGENT_NAME IS NOT NULL AND (SESS_STATUS IN ('M') OR ERROR_MESSAGE LIKE '%ODI-1266%')

AND SESS_NO IN (SELECT SESS_NO FROM (SELECT SESS_NO,ROW_NUMBER() OVER(PARTITION BY SESS_NAME, SCEN_VERSION ORDER BY LAST_DATE DESC) RAWNUM FROM LY_ODI_GZK.SNP_SESSION ) WHERE RAWNUM = 1))

)

 

UNION ALL

 

SELECT

/*流程监控:ODI问题流程最新记录【仅限调度活动的流程】*/

/*警告和ODI-1266(会话过时)*/

[SCHOOL] SCHOOL,--学校

业务系统 OPER_SYS,--业务系统

调度名称 PROCESS_NAME,--"调度名称/流程名称"

源对象 SRC_OBJ,--源对象

目标对象 TAG_OBJ,--目标对象

'['||LAGENT_NAME||'] '||调度周期 SCHEDULE,--调度周期

状态 SESS_STATUS,--状态

最新执行结束时间 LAST_SESS_END,--最新执行结束时间

报错信息 ERR_MESSAGE,--报错信息

TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss') TIMEFLAG

FROM (

SELECT DISTINCT

CASE WHEN XM2.PAR_I_FOLDER IS NOT NULL THEN (SELECT XM3.FOLDER_NAME FROM LY_ODI_GZK.SNP_FOLDER XM3

WHERE XM3.I_FOLDER=XM2.PAR_I_FOLDER)--三层根文件夹

WHEN XM.PAR_I_FOLDER IS NOT NULL THEN XM2.FOLDER_NAME--两层根文件夹

ELSE XM.FOLDER_NAME END 业务系统,--一层根文件夹

JK.I_POP 接口,

AGEN.SCEN_NAME 调度名称,

AGEN.LAGENT_NAME,

YB.TABLE_NAME 源对象,

JK.TABLE_NAME 目标对象,

CASE WHEN AGEN.STAT_PLAN = 'D' THEN '非活动' WHEN AGEN.STAT_PLAN = 'E' THEN '活动' WHEN AGEN.STAT_PLAN IS NULL THEN '无调度'

ELSE AGEN.STAT_PLAN END 调度状态,

case when agen.I_PLAN_AGENT is null then '/' --无调度

when agen.R_TIME||agen.s_type='1D' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

when agen.R_TIME||agen.s_type='1S' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second

when agen.R_TIME||agen.s_type='1W' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.R_TIME||agen.s_type='1M' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN AGEN.R_TIME||AGEN.S_TYPE='1H' THEN AGEN.S_HOUR||':'||AGEN.S_MINUTE||':'||AGEN.S_SECOND||'/H'

else agen.r_dur_interval||agen.r_interval_unit||(

case when agen.s_type='S' then '('||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||')'

when agen.s_type='W' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.s_type='M' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN agen.s_type='D' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

WHEN agen.s_type='Y' then ' & '||agen.S_MONTH||'.'||agen.S_DAY||' '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/Y'

else ' & '||agen.s_type end

) end 调度周期,

CASE WHEN SESS.SESS_STATUS = 'E' THEN '报错' ELSE '警告' END 状态,

TO_CHAR(SESS.SESS_END,'yyyy-mm-dd hh24:mm:ss') 最新执行结束时间,

CASE WHEN SESS.SESS_STATUS = 'E' AND SESS.ERROR_MESSAGE LIKE '%at %' THEN TO_CHAR(SUBSTR(SESS.ERROR_MESSAGE,1,INSTR(SESS.ERROR_MESSAGE,CHR(9)||'at ')-2)) ELSE TO_CHAR(SESS.ERROR_MESSAGE) END 报错信息

,AGEN.SCEN_NAME||''||AGEN.SCEN_VERSION 场景

FROM (SELECT * FROM LY_ODI_GZK.SNP_SESSION WHERE SCEN_NAME IS NOT NULL AND MASTER_AGENT_NAME IS NOT NULL AND (SESS_STATUS IN ('M') OR ERROR_MESSAGE LIKE '%ODI-1266%')

AND SESS_NO IN (SELECT SESS_NO FROM (SELECT SESS_NO,ROW_NUMBER() OVER(PARTITION BY SESS_NAME, SCEN_VERSION ORDER BY LAST_DATE DESC) RAWNUM FROM LY_ODI_GZK.SNP_SESSION ) WHERE RAWNUM = 1)) SESS

LEFT JOIN (SELECT * FROM ly_odi_gzk.SNP_PLAN_AGENT WHERE STAT_PLAN = 'E') AGEN ON (AGEN.SCEN_NAME||''||AGEN.SCEN_VERSION) = (SESS.SCEN_NAME||''||SESS.SCEN_VERSION)

LEFT JOIN LY_ODI_GZK.SNP_SCEN SCEN ON (SESS.SCEN_NAME||''||SESS.SCEN_VERSION) = (SCEN.SCEN_NAME||''||SCEN.SCEN_VERSION)

LEFT JOIN LY_ODI_GZK.SNP_PACKAGE CXB ON SCEN.I_PACKAGE = CXB.I_PACKAGE

LEFT JOIN LY_ODI_GZK.SNP_POP JK ON SCEN.I_POP = JK.I_POP

LEFT JOIN LY_ODI_GZK.SNP_TRT TRT ON SCEN.I_TRT = TRT.I_TRT

LEFT JOIN LY_ODI_GZK.SNP_FOLDER XM ON COALESCE(JK.I_FOLDER,CXB.I_FOLDER,TRT.I_FOLDER)=XM.I_FOLDER

LEFT JOIN LY_ODI_GZK.SNP_FOLDER XM2 ON XM.PAR_I_FOLDER = XM2.I_FOLDER

LEFT JOIN LY_ODI_GZK.SNP_SOURCE_TAB YB ON YB.I_DATA_SET = JK.I_POP

WHERE AGEN.STAT_PLAN = 'E'

)

 

UNION ALL

 

SELECT

/*流程监控:ODI问题流程最新记录(包括调度时间异常)【仅限调度活动的流程】*/

/*异常调度时间*/

[SCHOOL] SCHOOL,--学校

业务系统 OPER_SYS,--业务系统

调度名称 PROCESS_NAME,--"调度名称/流程名称"

源对象 SRC_OBJ,--源对象

目标对象 TAG_OBJ,--目标对象

'['||LAGENT_NAME||'] '||调度周期 SCHEDULE,--调度周期

CASE WHEN 不规律调度配置 = '1' THEN '请人工检查流程是否按照调度配置执行' ELSE '调度异常' END SESS_STATUS,--状态

最新执行结束时间 LAST_SESS_END,--最新执行结束时间

TRUNC(未执行时长)||'天'||TRUNC((未执行时长-TRUNC(未执行时长))*24)||'小时'||TRUNC(((未执行时长-TRUNC(未执行时长))*24-TRUNC((未执行时长-TRUNC(未执行时长))*24))*60)||'分钟 未运行新流程'||(CASE WHEN SESS_NAME IS NULL THEN ',从没执行过。' WHEN SESS_STATUS = 'R' THEN ',正在运行。' ELSE '' END) ERR_MESSAGE,--报错信息

TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss') TIMEFLAG

FROM (

SELECT DISTINCT

CASE WHEN XM2.PAR_I_FOLDER IS NOT NULL THEN (SELECT XM3.FOLDER_NAME FROM LY_ODI_GZK.SNP_FOLDER XM3

WHERE XM3.I_FOLDER=XM2.PAR_I_FOLDER)--三层根文件夹

WHEN XM.PAR_I_FOLDER IS NOT NULL THEN XM2.FOLDER_NAME--两层根文件夹

ELSE XM.FOLDER_NAME END 业务系统,--一层根文件夹

JK.I_POP 接口,

CASE WHEN SCEN.I_PACKAGE IS NOT NULL THEN CXB.PACK_NAME WHEN SCEN.I_POP IS NOT NULL THEN JK.POP_NAME ELSE TRT.TRT_NAME END 调度名称,

YB.TABLE_NAME 源对象,

JK.TABLE_NAME 目标对象,

case when agen.I_PLAN_AGENT is null then '/' --无调度

when agen.R_TIME||agen.s_type='1D' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

when agen.R_TIME||agen.s_type='1S' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second

when agen.R_TIME||agen.s_type='1W' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.R_TIME||agen.s_type='1M' then agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN AGEN.R_TIME||AGEN.S_TYPE='1H' THEN AGEN.S_HOUR||':'||AGEN.S_MINUTE||':'||AGEN.S_SECOND||'/H'

else agen.r_dur_interval||agen.r_interval_unit||(

case when agen.s_type='S' then '('||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||')'

when agen.s_type='W' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/W-'||agen.S_WEEK_DAY

when agen.s_type='M' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/M-'||agen.S_MONTH_DAY

WHEN agen.s_type='D' then ' & '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/D'

WHEN agen.s_type='Y' then ' & '||agen.S_MONTH||'.'||agen.S_DAY||' '||agen.s_hour||':'||agen.s_minute||':'||agen.s_second||'/Y'

else ' & '||agen.s_type end

) end 调度周期,

TO_CHAR((CASE WHEN SESS.SESS_STATUS IN ('W','R') THEN SESS.LAST_DATE ELSE SESS.SESS_END END),'yyyy-mm-dd hh24:mm:ss') 最新执行结束时间,

SYSDATE - (CASE WHEN SESS.SESS_NAME IS NULL THEN (SELECT MIN(T.FIRST_DATE) FROM LY_ODI_GZK.SNP_SESSION T) ELSE SESS.FIRST_DATE END) 未执行时长,

CASE WHEN SESS.SESS_NO IS NULL THEN (SYSDATE - (SELECT MIN(FIRST_DATE) FROM LY_ODI_GZK.SNP_SESSION))*24*60

WHEN SESS.SESS_END IS NULL THEN (SYSDATE - SESS.LAST_DATE)*24*60 ELSE

(CASE WHEN AGEN.S_TYPE = 'D' AND (SYSDATE - SESS.SESS_END)>=1 THEN (SYSDATE - TO_DATE(AGEN.S_YEAR||'-'||AGEN.S_MONTH||'-'||AGEN.S_DAY||' '||AGEN.S_HOUR||':'||AGEN.S_MINUTE||':'||AGEN.S_SECOND,'YYYY-MM-DD HH24:MI:SS'))+(SYSDATE - SESS.SESS_END - 1)*24*60

WHEN AGEN.R_TIME = '0' THEN (

CASE WHEN AGEN.R_INTERVAL_UNIT = 'H' THEN (SYSDATE - SESS.LAST_DATE)*24*60-AGEN.R_DUR_INTERVAL*60

WHEN AGEN.R_INTERVAL_UNIT = 'M' THEN (SYSDATE - SESS.LAST_DATE)*24*60-AGEN.R_DUR_INTERVAL

WHEN AGEN.R_INTERVAL_UNIT = 'S' THEN (SYSDATE - SESS.LAST_DATE)*24*60-AGEN.R_DUR_INTERVAL/60

ELSE -1 END)

ELSE -1 END) END 超时分钟数R,

SESS.SESS_NAME,

SESS.SESS_STATUS,

AGEN.LAGENT_NAME,

CASE WHEN AGEN.S_TYPE IN ('W','M','Y') THEN '1' ELSE '0' END 不规律调度配置

FROM LY_ODI_GZK.SNP_SCEN SCEN

INNER JOIN (SELECT * FROM LY_ODI_GZK.SNP_PLAN_AGENT WHERE STAT_PLAN = 'E') AGEN ON UPPER(AGEN.SCEN_NAME||AGEN.SCEN_VERSION) = UPPER(SCEN.SCEN_NAME||SCEN.SCEN_VERSION)

LEFT JOIN (SELECT * FROM LY_ODI_GZK.SNP_SESSION WHERE SCEN_NAME IS NOT NULL AND MASTER_AGENT_NAME IS NOT NULL

AND SESS_NO IN (SELECT SESS_NO FROM (SELECT SESS_NO,ROW_NUMBER() OVER(PARTITION BY SESS_NAME, SCEN_VERSION ORDER BY LAST_DATE DESC) RAWNUM FROM LY_ODI_GZK.SNP_SESSION ) WHERE RAWNUM = 1)

) SESS ON UPPER(SESS.SCEN_NAME||SESS.SCEN_VERSION) = UPPER(SCEN.SCEN_NAME||SCEN.SCEN_VERSION)

LEFT JOIN LY_ODI_GZK.SNP_PACKAGE CXB ON SCEN.I_PACKAGE = CXB.I_PACKAGE

LEFT JOIN LY_ODI_GZK.SNP_POP JK ON SCEN.I_POP = JK.I_POP

LEFT JOIN LY_ODI_GZK.SNP_TRT TRT ON SCEN.I_TRT = TRT.I_TRT

LEFT JOIN LY_ODI_GZK.SNP_FOLDER XM ON COALESCE(JK.I_FOLDER,CXB.I_FOLDER,TRT.I_FOLDER) = XM.I_FOLDER

LEFT JOIN LY_ODI_GZK.SNP_FOLDER XM2 ON XM.PAR_I_FOLDER = XM2.I_FOLDER

LEFT JOIN LY_ODI_GZK.SNP_SOURCE_TAB YB ON YB.I_DATA_SET = JK.I_POP

)WHERE 超时分钟数R-30>0 OR 不规律调度配置 = '1'

)WHERE OPER_SYS NOT IN ([exclude_projects])/*[]*/

order by SESS_STATUS,OPER_SYS;

你可能感兴趣的:(ODI,Oracle)