Apex

 #!/bin/bash


# Check if SID is passed as an argument

if [ -z "$1" ]; then

  echo "Usage: $0 <ORACLE_SID>"

  exit 1

fi


# Set the Oracle SID dynamically

export ORACLE_SID=$1


# Source Oracle environment variables using oraenv

. /usr/local/bin/oraenv <<< "$ORACLE_SID"


# Output file for the results

OUTPUT_FILE="${ORACLE_SID}_db_info.log"


# Function to log the output to a file

log_output() {

  echo "$1" >> "$OUTPUT_FILE"

}


# Start logging process

log_output "-------------------------------------"

log_output "DB Information for $ORACLE_SID"

log_output "-------------------------------------"


# 1. DB Growth (Tablespace Size Information)

log_output "-------------------------------------"

log_output "DB Growth (Tablespace Size Information for $ORACLE_SID)"

log_output "-------------------------------------"

sqlplus -S / as sysdba <<EOF >> "$OUTPUT_FILE"

SET LINESIZE 200

SET PAGESIZE 50

SELECT tablespace_name, 

       ROUND(SUM(bytes) / 1024 / 1024 / 1024, 2) AS total_gb,

       ROUND(SUM(bytes) / 1024 / 1024 / 1024 / 1024, 2) AS used_gb

FROM dba_data_files

GROUP BY tablespace_name;

EXIT;

EOF


# 2. APEX Installed Status

log_output "-------------------------------------"

log_output "APEX Installed Status for $ORACLE_SID"

log_output "-------------------------------------"

sqlplus -S / as sysdba <<EOF >> "$OUTPUT_FILE"

SET LINESIZE 200

SET PAGESIZE 50

SELECT status FROM apex_030200.WWV_FLOW_VERSION;

EXIT;

EOF


# 3. Character Set (NLS_CHARACTERSET)

log_output "-------------------------------------"

log_output "Character Set for $ORACLE_SID"

log_output "-------------------------------------"

sqlplus -S / as sysdba <<EOF >> "$OUTPUT_FILE"

SET LINESIZE 200

SET PAGESIZE 50

SELECT value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET';

EXIT;

EOF


# 4. TDE (Transparent Data Encryption) Enabled

log_output "-------------------------------------"

log_output "TDE Enabled Status for $ORACLE_SID"

log_output "-------------------------------------"

sqlplus -S / as sysdba <<EOF >> "$OUTPUT_FILE"

SET LINESIZE 200

SET PAGESIZE 50

SELECT wallet_type FROM v\$encryption_wallet;

EXIT;

EOF


# Final Message

log_output "-------------------------------------"

log_output "End of Information for $ORACLE_SID"

log_output "-------------------------------------"


echo "Output saved to $OUTPUT_FILE"

Comments

Popular posts from this blog

Database growth

P2

SQL Loader V3