Databases Reference
In-Depth Information
function sp {
time sqlplus "/ as sysdba"
} # sp
#-----------------------------------------------------------#
# find largest files below this point
function flf {
find . -ls | sort -nrk7 | head −10
}
#-----------------------------------------------------------#
# find largest directories consuming space below this point
function fld {
du -S . | sort -nr | head −10
}
#-----------------------------------------------------------#
# change directories to directory containing alert log file
function bdump {
cd /u01/app/oracle/diag/rdbms/o12c/o12c/trace
} # bdump
#-----------------------------------------------------------#
tbsp_chk.bsh
This script checks to see if any tablespaces are surpassing a certain fullness threshold. Store this script in a directory
such as HOME/bin . Make sure you modify the script to contain the correct username, password, and e-mail address for
your environment.
You also need to establish the required OS variables, such as ORACLE_SID and ORACLE_HOME . You can either
hard-code those variables into the script or call a script that sources the variables for you. The next script calls a script
(named oraset) that sets the OS variables (see Chapter 2 for the details of this script). You don't have to use this
script—the idea is to have a consistent and repeatable way of establishing OS variables for your environment.
You can run this script from the command line. In this example I passed it the database name (o12c) and wanted
to see what tablespaces had less than 20 percent space left:
$ tbsp_chk.bsh o12c 20
The output indicates that two tablespaces for this database have less than 20 percent space left:
space not okay
0 % free UNDOTBS1, 17 % free SYSAUX,
Here are the contents of the tbsp_chk.bsh script:
#!/bin/bash
#
if [ $# -ne 2 ]; then
echo "Usage: $0 SID threshold"
exit 1
fi
# either hard code OS variables or source them from a script.
# see Chapter 2 for details on using oraset to source oracle OS variables
. /var/opt/oracle/oraset $1
#
 
Search WWH ::




Custom Search