Post check
#!/bin/bash
# Set Oracle environment
export ORACLE_SID=<your_cdb_sid>
export ORAENV_ASK=NO
. oraenv > /dev/null
# Log file setup
LOG_DIR=/tmp/post_migration_check
mkdir -p $LOG_DIR
LOGFILE="$LOG_DIR/post_migration_check_$(date +%Y%m%d_%H%M%S).log"
# SQL execution wrapper
exec_sql() {
sqlplus -s "/ as sysdba" <<EOF
set pagesize 500
set linesize 200
set feedback off
set echo off
$1
exit
EOF
}
echo "=== Post Migration Certification Checks ===" | tee -a $LOGFILE
# 1. CDB & PDB open modes
echo -e "\n--- 1. CDB & PDB Open Modes ---" | tee -a $LOGFILE
exec_sql "SELECT name, open_mode, restricted FROM v\$pdbs;" | tee -a $LOGFILE
# 2. PDB violations
echo -e "\n--- 2. PDB Plug-in Violations ---" | tee -a $LOGFILE
exec_sql "SELECT * FROM pdb_plug_in_violations WHERE status='PENDING';" | tee -a $LOGFILE
# 3. Listener parameters
echo -e "\n--- 3. Listener Parameter ---" | tee -a $LOGFILE
exec_sql "show parameter listener;" | tee -a $LOGFILE
# 4. SGA info
echo -e "\n--- 4. SGA Parameters ---" | tee -a $LOGFILE
exec_sql "show parameter sga;" | tee -a $LOGFILE
# 5. PGA info
echo -e "\n--- 5. PGA Parameters ---" | tee -a $LOGFILE
exec_sql "show parameter pga;" | tee -a $LOGFILE
# 6. INVALID objects
echo -e "\n--- 6. INVALID Objects ---" | tee -a $LOGFILE
exec_sql "SELECT owner, object_type, object_name FROM dba_objects WHERE status='INVALID';" | tee -a $LOGFILE
# 7. DB components
echo -e "\n--- 7. Component Status ---" | tee -a $LOGFILE
exec_sql "SELECT comp_name, version, status FROM dba_registry;" | tee -a $LOGFILE
# 8. TDE wallet status
echo -e "\n--- 8. TDE Wallet Status (gv\$) ---" | tee -a $LOGFILE
exec_sql "SELECT inst_id, wallet_type, wallet_status FROM gv\$encryption_wallet;" | tee -a $LOGFILE
# 9. Encryption keys in PDB
echo -e "\n--- 9. Encryption Keys per PDB ---" | tee -a $LOGFILE
exec_sql "SELECT key_id, activating_pdbname FROM v\$encryption_keys;" | tee -a $LOGFILE
# 10. SSL connections
echo -e "\n--- 10. SSL Connections ---" | tee -a $LOGFILE
exec_sql "SELECT sid, serial#, network_service_banner FROM v\$session_connect_info WHERE network_service_banner LIKE '%SSL%';" | tee -a $LOGFILE
# 11. Encrypted tablespaces
echo -e "\n--- 11. Encrypted Tablespaces ---" | tee -a $LOGFILE
exec_sql "SELECT tablespace_name, encrypted FROM dba_tablespaces WHERE contents='PERMANENT';" | tee -a $LOGFILE
# 12. RMAN controlfile autobackup
echo -e "\n--- 12. RMAN Controlfile Autobackup ---" | tee -a $LOGFILE
exec_sql "SHOW ALL;" | tee -a $LOGFILE | grep -i controlfile
# 13. Autosys job check (manual or CLI)
echo -e "\n--- 13. Autosys Job Check ---" | tee -a $LOGFILE
if command -v autorep >/dev/null; then
autorep -J % -q | tee -a $LOGFILE
else
echo "Autosys not found or not in PATH. Please verify manually." | tee -a $LOGFILE
fi
# 14. OEM monitoring (basic alert example)
echo -e "\n--- 14. OEM Monitoring - Outstanding Alerts ---" | tee -a $LOGFILE
exec_sql "SELECT object_type, reason, message_level FROM dba_outstanding_alerts;" | tee -a $LOGFILE
# 15. SNOW entry check (custom table, update if needed)
echo -e "\n--- 15. SNOW Entries in PDB (Assumed custom table) ---" | tee -a $LOGFILE
exec_sql "SELECT * FROM pdb_snow_entries;" 2>/dev/null | tee -a $LOGFILE
# 16. Cloakware user check
echo -e "\n--- 16. Cloakware Users Present ---" | tee -a $LOGFILE
exec_sql "SELECT username FROM dba_users WHERE username IN ('OPS_USER', 'APP_USER', 'SERVICE_ACCT');" | tee -a $LOGFILE
echo -e "\n=== All Checks Completed Successfully. Log: $LOGFILE ==="
Comments
Post a Comment