#!/bin/bash
#
# ora_statspack <mode> <report_spec_in_configuration_file>
#
# <mode> := { SNAPSHOT | REPORT }
#
# <report_spec_in_configuration_file> := the name of the parameter in the 
# ORA_STATSPACK section that defines the time interval for the statspack report.
# Only for <mode> = REPORT
#

cd `dirname $0`

# -----
# Set environment
. ./oracle_env
if [ $? -ne 0 ] ; then
  echo 
  echo "Error: Cannot source Oracle's environment script './oracle_env'"
  echo
  exit 1
fi

# -----
# HOSTNAME is used, but normally not set in cronjobs

HOSTNAME=`uname -n`
export HOSTNAME

# Remember to include the directory where flush_test_values can
# be found ('/usr/bin' or '/usr/local/bin') in the PATH. Should be 
# set in the file where './oracle_env' is linked to.


# -----
# Exit silently, if the TEST_BEFORE_RUN command does
# not return the exit value 0.

perl test_before_run.pl oracle_tools.conf > /dev/null 2>&1 || exit


# -----
# Call the script.

# Set for decimal point, english messages and ISO date representation
# (for this client only).
# export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD hh24:mi:ss"
# (although it did not worked as expected)

perl ora_statspack.pl oracle_tools.conf $@

