#!/bin/bash
# Variables
ORACLE_USER="oracle" # Replace with your Oracle user
DB_STATUS_FILE="/tmp/db_status.log"
GGSCI_PATH="/usr/local/bin/ggsci" # Modify this to your GoldenGate installation path
# Function to check if databases are up and running
check_db_status() {
echo "Checking databases..."
ps -ef | grep pmon | grep -v grep > $DB_STATUS_FILE
# Count databases up and running
DB_COUNT=$(cat $DB_STATUS_FILE | wc -l)
if [ $DB_COUNT -gt 0 ]; then
echo "$DB_COUNT databases are up and running."
else
echo "No databases are up."
fi
}
# Function to check if GoldenGate exists
check_goldengate() {
echo "Checking for GoldenGate installation..."
if locate ggsci &>/dev/null; then
echo "GoldenGate is installed."
else
echo "GoldenGate not found."
fi
}
# Function to check databases with wallets
check_wallets() {
echo "Checking for databases with wallets..."
WALLET_COUNT=$(ls -ltr /u01/app/oracle/okv 2>/dev/null | grep -v total | wc -l)
if [ $WALLET_COUNT -gt 0 ]; then
echo "$WALLET_COUNT databases have wallets."
else
echo "No databases have wallets."
fi
}
# Function to perform Data Guard checks with dgmgrl
check_dgmgrl() {
echo "Performing Data Guard checks..."
su - $ORACLE_USER -c "dgmgrl -silent <<EOF
connect /;
show configuration;
exit;
EOF"
if [ $? -eq 0 ]; then
echo "Data Guard is in sync."
else
echo "Data Guard check failed."
fi
}
# Execute all checks
echo "Starting Oracle Database Health Checks..."
check_db_status
check_goldengate
check_wallets
check_dgmgrl
echo "Health check completed."





0 comments:
Post a Comment