用zabbix监控oracle dg从库是否应用日志的脚本

用zabbix监控oracle dg从库是否应用日志的脚本


1、首先在dg备库服务器上写如下脚本:
[root@hnagroupnet1 ~]# cat /zabbix/archivelog_bak.sh
#!/bin/bash
sqlplus -S / as sysdba  @/zabbix/archivelog2.sql
 
[root@hnagroupnet1 ~]# cat /zabbix/archivelog2.sql
set serveroutput on size 10000
set heading off
set feedback off
set linesize 255
spool /zabbix/archive.log
begin
for zabbix in (select count(*) cnt from v$archived_log where applied='NO' AND  first_time > sysdate - 1/48) loop
    if zabbix.cnt<>0 then
         dbms_output.put_line(' 10.72.24.137 archive error' );
    end if;
    for zabbix2 in (select count(*) cnt2 from v$archived_log where   next_time > sysdate - 1/48) loop
     if zabbix2.cnt2=0 then
     dbms_output.put_line('10.72.24.137 archivelog file not arrived' );
    else
       if  zabbix.cnt=0 then
         dbms_output.put_line('ok' );
       end if;
    end if;
end loop;
end loop;
end;
/
spool off;
exit

2、将上述脚本在dg服务器上加入执行计划:

[root@hnagroupnet1 ~]# crontab -l
*/5 * * * * su - oracle -c "sh /zabbix/archivelog_bak.sh"

3、在zabbix建立iterms:
键值:system.run["cat /zabbix/archive.log",]
注释: system.run[command,<mode>]    在主机上执行指定的命令.
4、建立触发器:

{10.72.24.137:system.run["cat /zabbix/archive.log",].str(ok,#2)}=0

描述:/zabbix/archive.log日志内容不为1则报警

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

转载于:http://blog.itpub.net/28916011/viewspace-1821144/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值