Since you are using Oracle 8i, you can now use the AFTER STARTUP and BEFORE SHUTDOWN triggers. You can execute any code you wish in the PL/SQL blocks for those triggers.
Otherwise, you can just add a line in your dbstart or dbshut scripts which call a program to run UTLBSTAT or UTLESTAT. For instance, I have a script which can run UTLBSTAT as such:
#!/bin/csh # stats_collect.sh # by Brian Peasland # 18 April 2002 # setenv PATH /usr/openwin/bin:.:/usr/local:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/etc:/usr/etc:/usr/sbin:/usr/dt/bin setenv ORAENV_ASK NO setenv ORACLE_SID $SID source /usr/local/bin/coraenv sqlplus system/manager @$ORACLE_HOME/utlbstat.sqlYou can make modifications for running UTLESTAT. Then just put one line in dbshut or dbstart to run this script for you!
One final note...UTLBSTAT/ESTAT are not nearly as good as 8i's new STATSPACK. STATSPACK gives you so much more information! You might want to look into using STATSPACK instead.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
This was first published in August 2002