Golden gate stop v1

#!/bin/bash


read -p "Enter the log directory: " log_dir


if [ -z "$log_dir" ]; then

    echo "Log directory not provided. Exiting."

    exit 1

fi


mkdir -p "$log_dir"


for value in $(locate setup_ogg | grep -E '/setup_ogg$'); do

    source $value

    cp $value $value_prepatch_bkp'$(date +"%Y%m%d%H%M%S")'


    GG_HOME=$(dirname "$value")

    GG_HOME_FILE=$(echo "$GG_HOME" | tr '/' '_')

    log_file="$log_dir/gg_info_$GG_HOME_FILE.log"


    cd "$GG_HOME"


    echo "==cccccces === ============" > "$log_file"

    echo "Executing 'info all' in $GG_HOME" >> "$log_file"


    ./ggsci <<EOF >> "$log_file"

    STOP ER * detail

EOF

done


# Capture the log without the header

export ORACLE_SID=$(ps -ef | grep '[a]sm_smon.*+ASM' | awk '{print $NF}' | cut -d '_' -f3)

source oraenv <<< "$ORACLE_SID"


agctl status goldengate > goldengate_status_log.txt


# Parse and extract running instances with manager names (formatted as node: manager)

running_instances_with_manager=$(grep "is running" goldengate_status_log.txt | awk '{gsub(/'\''/, ""); print $NF ":" $3}')


# Print the formatted running instances

echo "$running_instances_with_manager"


# Log in to respective nodes and run agctl status goldengate with manager name

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)


    # Logging before executing SSH command

    echo "Logging into $node_name to check Goldengate status for $manager_name" >> "$log_file"


    # SSH into the node and execute commands with logging

    ssh -q $node_name "

        export ORACLE_SID=\$(ps -ef | grep '[a]sm_smon.*+ASM' | awk '{print \$NF}' | cut -d '_' -f3)

        source oraenv <<< \"\$ORACLE_SID\"

        agctl status goldengate '$manager_name' >> '$log_file'

    "

done

Comments

Popular posts from this blog

Oratab Entries validate and add

deployment pre patch

Golden gate v1