Home > Oracle Tips > Oracle Database Administrator > Check for Oracle availability and tablespace capacity
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Check for Oracle availability and tablespace capacity


rick stehno
10.18.2001
Rating: -4.60- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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'
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 <$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 <$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.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

Other availability strategies
Creating a standby database in 10g
Steps for database replication
Service levels and resources: A decade of mismatch
Keeping data recovery site active
Data warehousing possible on a disaster recovery hot site?
Replication for high availability
Configure Data Guard on Windows NT
Questions about partitions, indexes, and parallelism
Know-IT-all Chapter Quiz #2: Backup and recovery for high availability
Hardware clustering vs. replication: A case study

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.

HomeNewsTopicsTipsAsk the ExpertsWebcastsWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts