STREAMS MONITORING

STREAMS_MONITORING :

create or replace PROCEDURE STREAMS_MONITORING AS
v_cap_status number;
v_prop_status number;
v_apply_status number;
v_apply_err_amt number;
v_subject VARCHAR2(250);
v_message VARCHAR2(500);
BEGIN

v_apply_err_amt :=0;
-- Check the status of stream capture
SELECT DECODE(STATUS, 'ENABLED', 1, 'DISABLED', 0 ) into v_cap_status
FROM DBA_CAPTURE
where capture_name ='STRM_CAPTURE';

DBMS_OUTPUT.PUT_LINE('Check the status of stream capture' ||v_cap_status );
if v_cap_status <> 1
then
admin.p_send_mail( sender=>'db-...-r3.idc.com',recipient=>'db-monitoring@amazon.com', ccrecipient=>'weifengz@amazon.com', subject=>'[FC1CN] Replication Failure: Replication Process From FC1CN to FCDW1CN fail!',message=>'Replicaton Process failure, pls contact DBA immediate');
-- Send alarm email and then exit the monitoring
DBMS_OUTPUT.PUT_LINE('return');
return;
end if;

-- Check the status of stream propagation
SELECT DECODE(s.SCHEDULE_DISABLED, 'Y', 0, 'N', 1 ) into v_prop_status
FROM DBA_QUEUE_SCHEDULES s, DBA_PROPAGATION p
WHERE p.DESTINATION_DBLINK = s.DESTINATION
AND s.SCHEMA = p.SOURCE_QUEUE_OWNER
AND s.QNAME = p.SOURCE_QUEUE_NAME;

DBMS_OUTPUT.PUT_LINE('Check the status of stream propagation' ||v_prop_status );
if v_prop_status <> 1
then
admin.p_send_mail( sender=>'db-...-r3.idc.com',recipient=>'db-monitoring@amazon.com', ccrecipient=>'weifengz@amazon.com', subject=>'[FC1CN] Replication Failure: Replication Process From FC1CN to FCDW1CN fail!',message=>'Replicaton Process failure, pls contact DBA immediate');
-- Send alarm email and then exit the monitoring
DBMS_OUTPUT.PUT_LINE('return');
return;
end if;

-- Check the status of apply
SELECT decode(status, 'ENABLED',1, 'DISABLED', 0) into v_apply_status
FROM DBA_APPLY@fcdw1cn.amazon
where apply_name ='STRM_APPLY';
DBMS_OUTPUT.PUT_LINE('Check the status of apply ' ||v_apply_status );

if v_apply_status <> 1
then
admin.p_send_mail( sender=>'db-...-r3.idc.com',recipient=>'db-monitoring@amazon.com', ccrecipient=>'weifengz@amazon.com',subject=>'[FC1CN] Replication Failure: Replication Process From FC1CN to FCDW1CN fail!',message=>'Replicaton Process failure, pls contact DBA immediate');
-- Send alarm email and then exit the monitoring
DBMS_OUTPUT.PUT_LINE('return');
return;
end if;

-- Check the apply error in destination database
select count(*) into v_apply_err_amt
from dba_apply_error@fcdw1cn.amazon
where apply_name ='STRM_APPLY';

DBMS_OUTPUT.PUT_LINE('----- BEGIN ERROR #' ||v_apply_err_amt );

if v_apply_err_amt > 0
then
SYS.DBMS_System.ksdwrt(2, 'ORA-00600: Replication Failure');
admin.p_send_mail( sender=>'db-...-r3.idc.com',recipient=>'db-monitoring@amazon.com', ccrecipient=>'weifengz@amazon.com', subject=>'[FC1CN] Replication Failure: Replication Process From FC1CN to FCDW1CN fail!',message=>'Replicaton Process failure, pls contact DBA immediate');
-- Send alarm email and then exit the monitoring
return;
end if;


EXCEPTION
WHEN OTHERS then
null ;

END;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/756652/viewspace-242479/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/756652/viewspace-242479/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值