Pre check database
#!/bin/bash
export ORAENV_ASK=NO
export ORACLE_SID=$1
export frame=$2
db_name=${ORACLE_SID%?}
. oraenv
report_file="pre_check_report_$(date +%F).log"
sqlplus -s / as sysdba <<EOF >> $report_file
@queries.sql
exit;
EOF
autosys.ksh -h $frame -d $db_name -c delete
dgmgrl / <<EOF >> $report_file
show configuration;
EOF
if grep -qE "ORA-16525|ORA-16596" "$report_file"; then
echo "Data Guard not available for $db_name" >> $report_file
fi
DB_NAME=$(grep -E "Standby Physical" $report_file | awk '{print $1}')
dgmgrl / <<EOF >> $report_file
show database "$DB_NAME";
EOF
export ASM_SID=$(ps -ef | grep [a]sm_smon.*+ASM | awk '{print $NF}' | cut -d'+' -f3)
. oraenv <<< "$ASM_SID"
srvctl status database -d $db_name -v
agctl status goldengate > goldengate_status_log.log
running_instances_with_manager=$(grep "is running" goldengate_status_log.log | awk '{gsub(/^\**|\**$/, "", $0); print $NF":"$3}')
echo "$running_instances_with_manager" >> $report_file
for instance_with_manager in $running_instances_with_manager; do
node_name=$(echo $instance_with_manager | cut -d':' -f1)
manager_name=$(echo $instance_with_manager | cut -d':' -f2)
echo "Logging into $node_name to check Goldengate status for $manager_name" >> "$report_file"
ssh $node_name <<EOF >> $report_file
export ORACLE_SID=$(ps -ef | grep [a]sm_smon.*+ASM | awk '{print $NF}' | cut -d'+' -f3)
. oraenv <<< "\$ORACLE_SID"
/auto/data.misc/oracle/ogg_distribution/automation_scripts/66_processes.sh
/auto/data.misc/oracle/ogg_distribution/automation_scripts/66_pumps.sh
EOF
done
# Extracting database info from report file
grep "$db_name" $report_file && echo "GG process available for this DB" >> $report_file || echo "No GG process found for this DB" >> $report_file
# Content of queries.sql
cat <<EOL > queries.sql
set linesize 200
set pagesize 100
col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
SELECT round(sum(used.bytes)/1024/1024/1024) || 'GB' "Database Size",
round(sum(used.bytes)/1024/1024/1024) "Used space",
round(free.p/1024/1024/1024) || 'GB' "Free space"
FROM (SELECT bytes FROM v\$datafile
UNION ALL
SELECT bytes FROM v\$tempfile
UNION ALL
SELECT bytes FROM v\$log) used,
(SELECT sum(bytes) as p FROM dba_free_space) free
GROUP BY free.p;
SELECT db_unique_name, open_mode FROM v\$database;
SELECT sysdate FROM dual;
SELECT service_name, COUNT(*) FROM gv\$session GROUP BY service_name;
set linesize 200
set pagesize 100
column WRL_TYPE format a20
column WRL_PARAMETER format a30
column STATUS format a10
column WALLET_TYPE format a10
column WALLET_ORDER format a10
column KEYSTORE_MODE format a10
column FULLY_BACKED_UP format a10
column CON_ID format 9999
SELECT * FROM v\$encryption_wallet;
clear columns
set linesize 80
set pagesize 14
set colsep ' '
SELECT tablespace_name, encrypted FROM dba_tablespaces;
echo "*********DBA Encrypted column********"
SELECT * FROM dba_encrypted_columns;
set linesize 200
set pagesize 100
column os_username format a30
column username format a30
SELECT os_username, username, MAX(timestamp), COUNT(*)
FROM DBA_AUDIT_TRAIL
WHERE action_name = 'LOGON' AND timestamp > sysdate-31
GROUP BY os_username, username;
column MAX(timestamp) format a30
echo "*********GoldenGate Process*********"
SELECT capture_name FROM dba_capture;
SELECT module, action FROM gv\$session WHERE action LIKE '066%';
SELECT DISTINCT substr(module, 5, 8) process
FROM gv\$session
WHERE username='GGUSER' AND module NOT LIKE '%endate%'
ORDER BY process;
EOL
Comments
Post a Comment