Sponsored Content
Top Forums Shell Programming and Scripting Error in Scripting to monitor tablespace in Oracle DB Post 302649093 by sandip250382 on Thursday 31st of May 2012 12:00:25 AM
Old 05-31-2012
Error in Scripting to monitor tablespace in Oracle DB

Buddies, I am writing the below script 'tab.sh' to monitor the tablespaces in Database:-
-------------------------------
Code:
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
sqlplus system/oracle as sysdba <<EOF 
spool /home/oracle/tablespace_analysis.log
set lines 2000
set pagesize 100
select a.tablespace_name as "tablespace",allocated as "size in gb", (a.allocated - nvl(b.freespace,0)) as "used space in gb",nvl(b.freespace,0) as "freespace in gb", (a.allocated - nvl(b.freespace,0))*100/a.allocated "percentage used",
100 - (a.allocated - nvl(b.freespace,0))*100/a.allocated "Percentage free"
from
(select tablespace_name, sum(bytes)/1024/1024/1024 allocated from dba_data_files group by tablespace_name ) a,
(select tablespace_name, sum(bytes)/1024/1024/1024 freespace from dba_free_space group by tablespace_name ) b
where a.tablespace_name = b.tablespace_name(+)
and (a.allocated - nvl(b.freespace,0))*100/a.allocated >85
order by 6 desc ;

spool off
EOF     
exit 0

________________________

However while executing the script, I am getting the below error:-

SQL> SQL> SQL> SQL> SP2-0042: unknown command "EOF" - rest of line ignored.

Any idea will be highly appreciated.

Last edited by joeyg; 05-31-2012 at 01:01 AM.. Reason: Please wrap code and data with CodeTags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix and Oracle scripting

Hello all, I have a script that is fully functional and satisfactory in oracle. I recently started spooling it's output into unix for processing and manipulation. I do have a few problems however: The output of some columns are altered in the unix output: 1) On oracle, the date comes with a... (7 Replies)
Discussion started by: Khoomfire
7 Replies

2. Shell Programming and Scripting

Shell Scripting with Oracle...

Hi guys, I have searched all the forums and searched the net as much as possible, but I carn't find any tutorials about shell scripting with Oracle. Has anyone come across any? Thanks for reading and in advance of posts, B14... (2 Replies)
Discussion started by: B14speedfreak
2 Replies

3. Shell Programming and Scripting

Shell Script to find the tablespace size in oracle.

Hi, I need to execute a script to find the tablespace size in oracle.But i get an error.:confused: Script Executed:- #!/bin/ksh ORACLE_SID= oracelinstance ORACLE_HOME= oracle path PATH=$ORACLE_HOME/bin export ORACLE_SID ORACLE_HOME PATH sqlplus... (4 Replies)
Discussion started by: vighna
4 Replies

4. Shell Programming and Scripting

error in script path for tablespace usage

Hi , I am trying to run this script in crontab but I get errors. When I run it explicitly like ./monitor_tblsp from another location then it runs fine . I am messing somewhere with paths but I don't know where and how . Please help . Here is the error part ./monitor_tblsp: touch: not... (2 Replies)
Discussion started by: capri_drm
2 Replies

5. Shell Programming and Scripting

Help needed for shell scripting for oracle.

Hi, Please see contains both files created for automating the data from oracle through shell. 1)a_p.ksh #!/bin/ksh LOG=/home/A_P.log MESSAGE=/home/MESSAGE_A_P.txt mail_list=/home/AP_MAIL_LIST.txt data=/home/spooled_A_P.log echo "`date` Starting execution for A_P COUNT" > $LOG ... (2 Replies)
Discussion started by: fidelis
2 Replies

6. Shell Programming and Scripting

tablespace monitoring script

I have prepared the below script to monitor the tablespace and alert the users whenever it reaches a threshold limit. #!/bin/sh . /home/.profile sqlplus -s $LOGON << .eof > $scripts/check_tablespace.temp set pages 0 select tablespace_name, free_percent from ( SELECT... (4 Replies)
Discussion started by: svajhala
4 Replies

7. Shell Programming and Scripting

Help please! Oracle scripting

Hi All, I'm completely new to shell scripting and i've found some old code (10 years), which would be suitable for me to facilitate database shutdowns throughout our systems. I'm on AIX 6 and i'm using 11gr2 Oracle. The problems seems to be with while read portion of this code: FLAG_SET=0... (2 Replies)
Discussion started by: Bluegenes
2 Replies

8. Shell Programming and Scripting

Script to check Oracle tablespace

I'm new to unix script, and I need to check the tablespaces daily, here is the script(quite simple), but it does not work. Did I missed something ? Please guide me, Many thanks ! #!/bin/sh echo "ORA TABLEASPACE:" sqlplus system/oracle as sysdba; set pagesize 9999; set linesize 132; ... (5 Replies)
Discussion started by: dehetoxic
5 Replies

9. Programming

Tablespace growth trend

Hi experts, I have the below details with me.How to calculate the tablespace growth between two dates. sample data(have data upto 1 year): INSTANCE_NAME DATE TABLESPACE_NAME MB_ALLOC MB_FREE MB_USED PCT_FREE PCT_USED MAX ---------------- ---------... (1 Reply)
Discussion started by: navsan420
1 Replies
ALTER 
TABLESPACE(7) SQL Commands ALTER TABLESPACE(7) NAME
ALTER TABLESPACE - change the definition of a tablespace SYNOPSIS
ALTER TABLESPACE name RENAME TO newname ALTER TABLESPACE name OWNER TO newowner DESCRIPTION
ALTER TABLESPACE changes the definition of a tablespace. You must own the tablespace to use ALTER TABLESPACE. To alter the owner, you must also be a direct or indirect member of the new owning role. (Note that superusers have these privileges automatically.) PARAMETERS
name The name of an existing tablespace. newname The new name of the tablespace. The new name cannot begin with pg_, as such names are reserved for system tablespaces. newowner The new owner of the tablespace. EXAMPLES
Rename tablespace index_space to fast_raid: ALTER TABLESPACE index_space RENAME TO fast_raid; Change the owner of tablespace index_space: ALTER TABLESPACE index_space OWNER TO mary; COMPATIBILITY
There is no ALTER TABLESPACE statement in the SQL standard. SEE ALSO
CREATE TABLESPACE [create_tablespace(7)], DROP TABLESPACE [drop_tablespace(7)] SQL - Language Statements 2010-05-14 ALTER TABLESPACE(7)
All times are GMT -4. The time now is 09:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy