Oracle dataguard 主備同步檢測指令碼
阿新 • • 發佈:2020-12-27
#!/bin/bash for SID in $(ps -fu oracle | grep pmon | grep -v grep | cut -d_ -f3- | sort); do export ORACLE_SID=$SID source ~/.bash_profile row=`sqlplus -silent '/ as sysdba' << EOSQL set pagesize 0 feedback off verify off heading off echo off select count(*) from v\\$dataguard_stats where name in ('transport lag','apply lag') and value is not null; EOSQL` if [ $row -eq 2 ]; then t_lag=`sqlplus -silent '/ as sysdba' << EOSQL set pagesize 0 feedback off verify off heading off echo off select to_number(substr(value,2,2))*1440+to_number(substr(value,5,2))*60+to_number(substr(value,8,2)) from v\\$dataguard_stats where name ='transport lag'; EOSQL` a_lag=`sqlplus -silent '/ as sysdba' << EOSQL set pagesize 0 feedback off verify off heading off echo off select to_number(substr(value,2,2))*1440+to_number(substr(value,5,2))*60+to_number(substr(value,8,2)) fro