Scan listener capture


***Main script****


#!/bin/bash


# Assign the provided OUTPUT_DIRECTORY to a variable

OUTPUT_DIRECTORY="$1"


# Function to log output

log_output() {

    local title="$1"

    local command="$2"


    # Determine the terminal width (columns)

    columns=$(tput cols)


    # Create a separator line with the determined width

    separator_line=$(printf "%${columns}s\n" | tr '''-')


    # Log section title with section number

    echo "$separator_line" >> "$LOG_FILE"

    echo "Section $section_counter: $title" >> "$LOG_FILE"

    echo "$separator_line" >> "$LOG_FILE"


    # Increment section counter

    ((section_counter++))


    # Execute command and log its output

    eval "$command" >> "$LOG_FILE" 2>&1


    # Append separator line after command output

    echo "$separator_line" >> "$LOG_FILE"

}


# Function to run listener capture.sh

run_listener_capture() {

    sh listener_capture.sh "$OUTPUT_DIRECTORY"

}


# Log output for Capture Listener Info

log_output "Capture Listener Info" "run_listener_capture"



*******

listener_capture.sh


#!/bin/bash


# Assign the provided OUTPUT_DIRECTORY to a variable

OUTPUT_DIRECTORY="$1"


# Set ORACLE_SID

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


# Set environment

source oraenv <<< "$ORACLE_SID"


# Specify the file to store listener information

listener_info_file="$OUTPUT_DIRECTORY/listener_info.log"


# Capture listener names and current nodes, logging activity

srvctl status scan_listener -all | awk '/LISTENER_SCAN[0-9]+/ {listener=$3; getline; print listener, $NF}' > "$listener_info_file" 2>&1


# Display Listener Information

cat "$listener_info_file"

Comments

Popular posts from this blog

SQL Loader V3

Db Unix

Standby redo log add