Tip

Tablespace monitor for autoextend

This code for DBAs provides a way to proactively indicate how much total logical disk space is available for tablespaces using the autoextend feature of Oracle on its datafiles. The resulting report sums bytes by tablespace. The output of this code can be used as a stand-alone report or (without headings) the output can be manipulated within a UNIX shell script to capture high percent usage or low available space by tablespace and send an alert by various means.

When autoextend is set, tablespace monitor scripts need to account for the sum of all MAXBYTES of the datafiles of each tablespace, not the current space usage and freespace. The output of this script can be manipulated with UNIX to look for high percent usage to truly know when a datafile is needed based on the maximum size of the tablespace's datafile after it is fully autoextended. The code has been tested on Oracle 8.1.x.

 rem * TBSP_monitor.sql rem * rem * This script reports on the allocated space in each tablespace, the rem * amount of free space for each tablespace, and percentage of allocated rem * space that is used. spool /sys/dba/controlm/scripts/TBSP_monitor.lst set sqlcase mixed set pause off set pagesize 0 set echo off set feedback off set linesize 90 ttitle off rem col value NEW_VALUE xdbname noprint format a1 trunc rem select value from v$parameter rem where name='db_name'; rem ttitle center 'Free Space by Tablespace Report' skip 1 - rem center 'Database Instance: 'xdbname

    Requires Free Membership to View

col tablespace_name heading 'Tablespace' form A20 col sum(b.maxbytes) heading '# Bytes' form 999,999,999,990 col (sum(b.maxbytes)-sum(nvl(b.bytes,0))) heading '# Free' form 999,999,999,990 col sum(nvl(b.bytes,0)) heading '# Used' form 999,999,999,990 col (sum(nvl(b.bytes,0))/(sum(nvl(b.maxbytes,1))))*100 heading '% Used' form 990 select b.tablespace_name,sum(b.maxbytes), (sum(b.maxbytes) - sum(nvl(b.bytes,0))), sum(nvl(b.bytes,0)), (sum(nvl(b.bytes,0))/(sum(nvl(b.maxbytes,1))))*100 from sys.dba_data_files b where tablespace_name not in ('RBS') group by b.tablespace_name order by b.tablespace_name; spool off exit rem * rem * End of TBSP_monitor.sql

 

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.


This was first published in December 2002

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.