Tip

Check for Oracle availability and tablespace capacity

Checking Oracle for availability requires more than just a ping or a 'ps -ef | grep oracle' command. I believe it requires a test accessing Oracle using SQL*Net to verify that the listener is also up and running -- this would be the access that a user would normally use. By actually logging on to the instance, you verify that the instance will accept logins whereas if you only do the above checks, how would you know if logins are not accepted due to archiver log waits?

Along with Oracle being alive and accessible, I also check to make sure it can be used, so I also check for tabalespace capacity.

I have written a few scripts that allows me to check:

  1. if all of the Oracle instances are up
  2. if any of the extents have reached their maximum limit
  3. if any of the tablespaces are running short of freespace

The script can be run from crontab with any interval you feel comfortable with. This script will also page or email the support personnel when any of the above exceptions are met.

If there are any other tests that you would like to do, this script can be easily modified to include them. I use this Monitororcl script as a template and just add functionality at the end.

The query_oracle_instances.sh script that is called from crontab:

 #!/bin/ksh . /u01/home/oracle/.profile /u01/app/oracle/admin/monitororcl 'cat /u01/app/oracle/admin/Get_Oracle_Instance_List'

    Requires Free Membership to View

exit

The Get_Oracle_Instance_List script:

 instance_name1 tnsname1 sys_password_for_this_instance instance_name2 tnsname2 sys_password_for_this_instance instance_name3 tnsname3 sys_password_for_this_instance

Here is the MONITORORCL script:

 #!/bin/ksh #script : Rick Stehno # script will monitor to see if Oracle is up while [ "$1" != "" ] do ORACLE_INSTANCE=$1 ORACLE_TNS=$2 USR_ID=sys USR_PASS=$3 # echo "Instance: [$ORACLE_INSTANCE]" # echo "TNS [$ORACLE_TNS]" # echo "PASS: [$USR_PASS]" LOGFIL=/u01/app/oracle/admin/monitordev1.out NOTIFY_LIST=userid1@mobilephone.com,userid2,userid3@pagercompany.com # # check for critical segments are not reaching maxextents # sqlplus -s <<EOF1 >$LOGFIL 2>/dev/null $USR_ID/$USR_PASS@$ORACLE_TNS set pages 0 select distinct 'YES' from dba_segments where extents >= (max_extents-5) and segment_name not like '1.%'; EOF1 grep -i '^ORA-' $LOGFIL >/dev/null if [ $? -eq 0 ] then echo "$0 failed: check $ORACLE_INSTANCE for problems" | /bin/mailx -s "${ORACLE_INSTANCE} : Script failed" $NOTIFY_LIST exit 1 fi MAXEXTENTS_REACHED=`awk '{ print $1 }' $LOGFIL` if [ "$MAXEXTENTS_REACHED" = "YES" ] then echo "$0 failed: $ORACLE_INSTANCE max extents reached" | /bin/mailx -s "${ORACLE_INSTANCE} : max extents reached" $NOTIFY_LIST exit 1 fi # # check for unable to allocate next segment # sqlplus -s <<EOF2 >$LOGFIL 2>/dev/null $USR_ID/$USR_PASS@$ORACLE_TNS set pages 0 select distinct 'YES' from dba_segments ds where next_extent > (select max(bytes) from dba_free_space where tablespace_name = ds.tablespace_name); EOF2 grep -i '^ORA-' $LOGFIL >/dev/null if [ $? -eq 0 ] then echo "$0 failed: check $ORACLE_INSTANCE for problems" | /bin/mailx -s "${ORACLE_INSTANCE} : Script failed" $NOTIFY_LIST exit 1 fi POSSIBLE_NEXTEXT_FAIL=`awk '{print $1 }' $LOGFIL` if [ "$POSSIBLE_NEXTEXT_FAIL" = "YES" ] then echo "$0 failed: $ORACLE_INSTANCE cannot extend segment" | /bin/mailx -s "${ORACLE_INSTANCE} : max extents reached" $NOTIFY_LIST exit 1 fi shift 3 # echo "shift done" done echo "Successful completion of $0" `date` exit 0

 

For More Information

  • What do you think about this tip? E-mail us at editor@searchDatabase.com with your feedback.
  • The Best Oracle Web Links: tips, tutorials, scripts, and more.
  • Have an Oracle tip to offer your fellow DBA's? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical Oracle questions--or help out your peers by answering them--in our live discussion forums.
  • Check out our Ask the Experts feature: Our SQL, Database Design, Oracle, SQL Server, DB@, metadata, and datawarehousing gurus are waiting to answer your toughest questions.


This was first published in October 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.