 |
|
Distributing the Table Reports via Email
Oracle Tips by Burleson Consulting
|
Now that we see the value of these reports, we
can look at how we can easily automate the e-mail distribution of the
statistics reports. As we noted, the summary of size and growth
statistics are of interest to top MIS management, and we can automate
the distribution by sending them e-mail each week showing the total
change in database sizes. Here is the report generation script:
run_object_report.ksh
#!/bin/ksh
# Validate the Oracle database name with
# lookup in /var/opt/oracle/oratab
TEMP=`cat /var/opt/oracle/oratab|grep \^$1:|\
cut -f1 -d':'|wc -l`
tmp=`expr TEMP` # Convert string to number
if [ $tmp -ne 1 ]
then
echo "Your input $1 is not a valid ORACLE_SID."
exit 99
fi
# Here we must set the environment . . . .
ORACLE_SID=$1
export ORACLE_SID
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep $ORACLE_SID:|cut -f2
-d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
MON=`echo /export/home/oracle/obj_stat`
export MON
sqlplus perfstat/perfstat<<!
spool ${MON}/stats_rpt.lst
@${MON}/rpt_object_stats
spool off;
exit;
!
#************************************
# Mail the Object Statistics Reports
#************************************
cat $MON/stats_rpt.lst|mailx -s "Weekly Statistics Summary" \
donald@remote-Remote DBA.net \
jim@us.oracle.com \
larry@oracle.com
Note that you will need to make several changes
to customize this report for your environment:
1.
The preceding listing uses the Solaris location of the oratab
file in /var/opt/oracle. If you are using AIX or HP/UX, you will want
to change this to the /etc directory.
2.
Make sure you change the e-mail addresses to match the
distribution list at your organization.
3.
Set the $MON UNIX variable to the location of your object
statistics scripts.
Here is an example of the UNIX crontab file
that you would use to execute this report generation script:
#**********************************************************
# These are the statspack extension reports for tables & indexes
#**********************************************************
30 07 1 * * /home/obj_stat/get_object_stats.ksh PRODEDI > /dev/null
Note from the crontab listing that you must pass your
ORACLE_SID as an argument to this script. The crontab entry says to
run the report at 7:30 a.m.
each Monday, and passes the ORACLE_SID name of PRODEDI to the script.
This is an excerpt from "Oracle9i
High Performance tuning with STATSPACK" by Oracle Press.
 |
If you like Oracle tuning, you may enjoy the new book "Oracle
Tuning: The Definitive Reference", over 900 pages
of BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |
 |
Expert Remote DBA
BC is America's oldest and largest Remote DBA Oracle support
provider. Get real Remote DBA experts, call
BC Remote DBA today. |
 |
|