Thursday, 19 June 2025

Filled under:

 #!/bin/bash


echo "🔍 Oracle Listener + DB Diagnostics Script"

echo "------------------------------------------"


ORACLE_HOME=$(ps -ef | grep pmon | grep -v grep | awk -F'/' '{print "/"$2"/"$3"/"$4}' | uniq)

LISTENER_LOG="${ORACLE_HOME}/network/log/listener.log"


echo -e "\n🧪 Checking Listener Status..."

lsnrctl status | tee /tmp/listener_status.txt | grep -E "Service|READY|FAILURE|Connecting"


echo -e "\n🧪 Checking DB Services Registration..."

ps -ef | grep pmon | grep -v grep

echo "Try running in SQL: ALTER SYSTEM REGISTER;"


echo -e "\n🧪 Checking Resource Limits from DB..."

sqlplus -s / as sysdba <<EOF

SET LINESIZE 200

COLUMN resource_name FORMAT A25

SELECT resource_name, current_utilization, max_utilization, limit_value 

FROM v\$resource_limit 

WHERE resource_name IN ('processes','sessions');

EXIT;

EOF


echo -e "\n🧪 Checking OS CPU and Memory Status..."

echo "CPU Load:"

uptime

echo "Memory:"

free -g

echo "Swap Usage:"

swapon --show


echo -e "\n🧪 Checking Listener Log Size..."

du -sh "$LISTENER_LOG" 2>/dev/null

tail -n 10 "$LISTENER_LOG"


echo -e "\n🧪 Checking Disk Space..."

df -h | grep -v tmpfs


echo -e "\n🧪 Checking for Wallet or TCPS SSL Config..."

grep -Ei 'wallet|ssl' $ORACLE_HOME/network/admin/sqlnet.ora 2>/dev/null

grep -Ei 'wallet|ssl' $ORACLE_HOME/network/admin/listener.ora 2>/dev/null


echo -e "\n✅ Diagnostics Complete."

0 comments:

Post a Comment