Sponsored Content
Top Forums Shell Programming and Scripting Error in Scripting to monitor tablespace in Oracle DB Post 302649107 by pravin27 on Thursday 31st of May 2012 01:07:57 AM
Old 05-31-2012
How about this ?
Code:
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
echo "
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;
exit" | sqlplus system/oracle as sysdba
   
exit 0

This User Gave Thanks to pravin27 For This Post:
 

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
nvlist_add_boolean(9F)					   Kernel Functions for Drivers 				    nvlist_add_boolean(9F)

NAME
nvlist_add_boolean, nvlist_add_boolean_value, nvlist_add_byte, nvlist_add_int8, nvlist_add_uint8, nvlist_add_int16, nvlist_add_uint16, nvlist_add_int32, nvlist_add_uint32, nvlist_add_int64, nvlist_add_uint64, nvlist_add_string, nvlist_add_nvlist, nvlist_add_nvpair, nvlist_add_boolean_array, nvlist_add_int8_array, nvlist_add_uint8_array, nvlist_add_nvlist_array, nvlist_add_byte_array, nvlist_add_int16_array, nvlist_add_uint16_array, nvlist_add_int32_array, nvlist_add_uint32_array, nvlist_add_int64_array, nvlist_add_uint64_array, nvlist_add_string_array, nvlist_t - value pair functions SYNOPSIS
#include <sys/nvpair.h> int nvlist_add_boolean(nvlist_t *nvl, const char *name); int nvlist_add_boolean_value(nvlist_t *nvl, const char *name, boolean_t val); int nvlist_add_byte(nvlist_t *nvl, const char *name, uchar_t val); int nvlist_add_int8(nvlist_t *nvl, const char *name, int8_t val); int nvlist_add_uint8(nvlist_t *nvl, const char *name, uint8_t val); int nvlist_add_int16(nvlist_t *nvl, const char *name, int16_t val); int nvlist_add_uint16(nvlist_t *nvl, const char *name, uint16_t val); int nvlist_add_int32(nvlist_t *nvl, const char *name, int32_t val); int nvlist_add_uint32(nvlist_t *nvl, const char *name, uint32_t val); int nvlist_add_int64(nvlist_t *nvl, const char *name, int64_t val); int nvlist_add_uint64(nvlist_t *nvl, const char *name, uint64_t val); int nvlist_add_string(nvlist_t *nvl, const char *name, char *val); int nvlist_add_nvlist(nvlist_t *nvl, const char *name, nvlist_t *val); int nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp); int nvlist_add_boolean_array(nvlist_t *nvl, const char *name, boolean_t *val, uint_t nelem); int nvlist_add_byte_array(nvlist_t *nvl, const char *name, uchar_t *val, uint_t nelem); int nvlist_add_int8_array(nvlist_t *nvl, const char *name, int8_t *val, uint_t nelem); int nvlist_add_uint8_array(nvlist_t *nvl, const char *name, uint8_t *val uint_t nelem); int nvlist_add_int16_array(nvlist_t *nvl, const char *name, int16_t *val, uint_t nelem); int nvlist_add_uint16_array(nvlist_t *nvl, const char *name, uint16_t *val, uint_t nelem); int nvlist_add_int32_array(nvlist_t *nvl, const char *name, int32_t *val, uint_t nelem); int nvlist_add_uint32_array(nvlist_t *nvl, const char *name, uint32_t *val, uint_t nelem); int nvlist_add_int64_array(nvlist_t *nvl, const char *name, int64_t *val, uint_t nelem); int nvlist_add_uint64_array(nvlist_t *nvl, const char *name, uint64_t *val, uint_t nelem); int nvlist_add_string_array(nvlist_t *nvl, const char *name, const *char *val, uint_t nelem); int nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **val, uint_t nelem); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
nvl The nvlist_t to be processed. nvp The nvpair_t (name-value pair) to be processed. name Name of the name-value pair (nvpair). nelem Number of elements in value (that is, array size). val Value or starting address of the array value. DESCRIPTION
These functions add a new name-value pair to an nvlist_t. The memory allocation policy follows that specified in nvlist_alloc(), nvlist_unpack(), or nvlist_dup(). See nvlist_alloc(9F). The uniqueness of nvpair name and data types follows the nvflag argument specified in nvlist_alloc(). If NV_UNIQUE_NAME was specified for nvflag, existing nvpairs with matching names are removed before the new nvpair is added. If NV_UNIQUE_NAME_TYPE was specified for nvflag, existing nvpairs with matching names and data types are removed before the new nvpair is added. If neither was specified for nvflag, the new nvpair is unconditionally added at the end of the list. The library preserves the order of the name-value pairs across packing, unpacking, and duplication. Multiple threads can simultaneously read the same nvlist_t, but only one thread may actively change a given nvlist_t at a time. The caller is responsible for the synchronization. The nvlist_add_boolean() function is deprecated and the nvlist_add_boolean_value() function is used instead. RETURN VALUES
0 success EINVAL invalid argument ENOMEM insufficient memory CONTEXT
These functions can be called from interrupt context only if(1) the default allocator is used and the KM_NOSLEEP flag is set, or(2) the specified allocator did not sleep for free memory (for example, if it uses a pre-allocated buffer for memory allocations). See nvlist_alloc(9F) for a description of pluggable allocators and KM_NOSLEEP. These functions can be called from user context in all cases. SunOS 5.10 2 Feb 2004 nvlist_add_boolean(9F)
All times are GMT -4. The time now is 05:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy