UNIX command for ALERT LOG FILE
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: UNIX command for ALERT LOG FILE

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    59

    UNIX command for ALERT LOG FILE

    hi dba gurus, how to monitor the alert log files while the database is up and running. pls tel me the UNIX commands for tat, thanks in advance

  2. #2
    Join Date
    Apr 2008
    Location
    Bangalore
    Posts
    96
    go to the directory where the archivelogs are kept

    and

    >tail -f alertsid.log

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    The old-n-good way?

    cd to the appropriate directory
    vi the alertlog
    Shift-g to go to the end -you want to check from the bottom up.
    Check for Oracle errors from the bottom up -until you reach the point of your previous visit to this instance's alertlog - using ?ORA-
    Investigate and document each error you find -take action when needed or document why you are doing nothing.

    Once you get bored of doing this in a daily basis you will figure out how to put together a more automatic approach to alertlog monitoring.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  4. #4
    Join Date
    Apr 2008
    Location
    Bangalore
    Posts
    96
    tail -f log will help in viewing the db events dynamically(but you cant see the history as Davey said)...while as the old method doesn't let you view any new activity after which the log has been opened using vi.

  5. #5
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,021
    Here is a script that I had been working on. You will need a set_oracle_env script that is customized for your environment. If you delete an alert log, Oracle will recreate it then next time it needs to write something to the alert log. You can also use OEM to monitor the alert log.


    #!/usr/bin/bash
    # set -x
    #
    # This shell program does a diff of the current logfile and compares it with
    # the previous log file, looks for and logs any errors that it finds. Then
    # saves the current log file as the old log file to track new changes that
    # havnt happened yet.
    #
    # Make sure that the sid name has been passed in.
    if [ $# -lt 1 ];
    then
    echo ""
    echo " ERROR : Invalid number of arguments"
    echo " Usage : backup_database "
    exit 1
    fi
    . /oracle/bin/set_oracle_env.sh ${1}

    export RECIPIENTS="bbyrd@andrew.cmu.edu"
    export SOURCE_ALERT_FILE=$ORACLE_ADMIN/bdump/alert_${ORACLE_SID}.log
    export TEMP_ALERT_FILE="$ORACLE_ADMIN/bdump/tmp_${ORACLE_SID}_alert.log"
    export LAST_ALERT_FILE="$ORACLE_ADMIN/bdump/saved_${ORACLE_SID}_alert.log"
    export MAIL_ALERT_FILE="$ORACLE_ADMIN/bdump/mail_${ORACLE_SID}_alert.log"
    export ERROR_ALERT_FILE="$ORACLE_ADMIN/bdump/error_${ORACLE_SID}_alert.log"

    while [ 1 ]
    do
    # Last Alert log file should already exist. If it doesnt it needs to be created.
    touch ${LAST_ALERT_FILE}

    # Copy the current Alert log to a temp file in case something changes after the diff.
    cp $SOURCE_ALERT_FILE $TEMP_ALERT_FILE

    # Find differences and filter out extraneous stuff that would get picked up as an error
    diff ${TEMP_ALERT_FILE} ${LAST_ALERT_FILE} | grep -v "end backup" | grep -v "begin backup" > ${MAIL_ALERT_FILE}
    # append any errors to the error file
    grep -i "ORA-" ${MAIL_ALERT_FILE} > ${ERROR_ALERT_FILE}
    grep -i "error " ${MAIL_ALERT_FILE} >> ${ERROR_ALERT_FILE}
    grep -i "SHUT " ${MAIL_ALERT_FILE} >> ${ERROR_ALERT_FILE}
    grep -i "START " ${MAIL_ALERT_FILE} >> ${ERROR_ALERT_FILE}
    cat ${ERROR_ALERT_FILE}
    # if there are errors in the error file then email to all of the new entries
    if [ -s ${ERROR_ALERT_FILE} ];
    then
    echo "To: ${RECIPIENTS}" > /tmp/error.mail
    echo "From: ${ORACLE_SID}" >> /tmp/error.mail
    echo "Subject: Something is fishy in ${ORACLE_SID}" >> /tmp/error.mail
    echo >> /tmp/error.mail
    cat ${MAIL_ALERT_FILE} >> /tmp/error.mail
    cat /tmp/error.mail | /bin/mail ${RECIPIENTS}
    fi
    # update the saved file with the temp file
    rm ${LAST_ALERT_FILE}
    mv ${TEMP_ALERT_FILE} ${LAST_ALERT_FILE}

    # remove the working files
    rm ${MAIL_ALERT_FILE}
    rm ${ERROR_ALERT_FILE}
    # wait one minute then repeat
    sleep 60
    done
    this space intentionally left blank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width