用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/