Data guard sync status
#!/bin/bash
LOG_DIR="/path/to/log/files"
# Loop through all Oracle SIDs
for SID in $(ps -ef | grep '[o]ra_smon' | awk '{print $NF}' | cut -d '_' -f3); do
export ORACLE_SID=$SID
dgmgrl / <<EOF > $LOG_DIR/DR_log_config_$SID.txt
show configuration
EOF
# Check if Data Guard configuration is not available
if grep -qE "ORA-16525" $LOG_DIR/DR_log_config_$SID.txt; then
echo "Data Guard not available for $SID" > $LOG_DIR/DR_log_all_databases.txt
continue
fi
DB_NAME=$(grep -E "Standby|Physical" $LOG_DIR/DR_log_config_$SID.txt | awk '{print $1}')
dgmgrl / <<EOF > $LOG_DIR/DR_log_status_$DB_NAME.txt
show database "$DB_NAME"
EOF
TRANSPORT_LAG=$(cat $LOG_DIR/DR_log_status_$DB_NAME.txt | grep -E "Transport Lag" | awk '{print $4}')
APPLY_LAG=$(cat $LOG_DIR/DR_log_status_$DB_NAME.txt | grep -E "Apply Lag" | awk '{print $4}')
if [[ "$TRANSPORT_LAG" == "0" && "$APPLY_LAG" == "0" ]]; then
echo "Sync Successful for $DB_NAME" > $LOG_DIR/DR_log_sync_status.txt
else
echo "Out of Sync for $DB_NAME" > $LOG_DIR/DR_log_sync_status.txt
fi
done
Comments
Post a Comment