Phone (800) 766-1884 for immediate Oracle support & training
Free Oracle Tips

Home Home
Oracle Monitoring
Growth Monitoring
Emergency DBA Support
Installs & Upgrades
Oracle Migration
Oracle Support Plan
Oracle SQL Tuning
Oracle Performance Tuning

 Our Remote DBA Clients

 

Free Oracle Tips


 
HTML Text

Free Oracle App Server Tips


 
HTML Text

Donald K. Burleson

Oracle Tips

 

A tablespace-full alert script

Here is a great script to alert the DBA whenever a tablespace grows beyond 95% full.  This script can be run with a Unix cron every tem minutes, and send a pager alert or e-mail to the DBA whenever a data file is needed for a tablespace.

Of course, many shops are using the AUTOEXTEND feature for tablespaces, in which case you should be monitoring your filesystems, and not just the Oracle tablespaces.

REM © 1996 by Donald K. Burleson

SET ECHO OFF;

SET TERM OFF;

SET TIMING OFF;

SET HEAD OFF;

SET FEED OFF;

CREATE TABLE temp_ts (tablespace_name,total_bytes,free_bytes,max_chunk)

  AS

  SELECT tablespace_name, NVL(SUM(bytes), 1), 1, 1

  FROM dba_data_files

  GROUP BY tablespace_name;

 

  UPDATE temp_ts a

  SET a.free_bytes = (SELECT NVL(SUM(b.bytes), 1)

                      FROM dba_free_space b

                      WHERE b.tablespace_name = a.tablespace_name);

  COMMIT;

  UPDATE temp_ts a

  SET a.max_chunk = (SELECT NVL(MAX(b.bytes), 1)

                     FROM dba_free_space b

                     WHERE b.tablespace_name = a.tablespace_name);

  COMMIT;

 

  REM ********************************************************************

  REM Display tablespaces more than 95% full.

********************************************************************

 

  SELECT

         tablespace_name                                     ||

         ' is '                                              ||

         TO_CHAR(ROUND(100-(free_bytes*100/total_bytes), 2)) ||

         '% full.' T

  FROM temp_ts

  WHERE 95 < 100-(free_bytes*100/total_bytes)

  ORDER BY tablespace_name;

Here is a sample of the output from this script, alerting you to tablespace that are almost full and tables that cannot take a NEXT extent.

NON-EMERGENCY ORACLE ALERT. Contact the DBA and report this error ===>Sun Feb 18 07:00:02 EST 2001 BOOKD is 100% full. BOOKD READER BOOK TABLE BOOKD READER PAGE TABLE BOOKD READER PAGE_IMAGE TABLE BOOKD READER SAMPLE_CONTROL TABLE BOOKD READER TOC_ENTRY TABLE

You can also easily extend this script to send you an e-mail alert when the tablespace become too full.

If you like Oracle tuning, you might enjoy my latest book “Oracle Tuning: The Definitive Reference” by Rampant TechPress.  It’s only $41.95(I don’t think it is right to charge a fortune for books!) and you can buy it right now at this link:

http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

 

 

 

 

 

Burleson Oracle consulting & training



 

 

WISE Oracle monitoring software
 

 

Oracle forum for DBA 

 

Rampant TechPress Oracle book publisher

image 

  

 
E-mail us for BC Oracle support:   

Copyright © 1996 -  2009 by Burleson Enterprises, Inc. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.