##################
# About: This files contains step  by step installation and usage instructions
#        for "CoMinder SpaceStat" scripts collection 
#        Read carefully all the file before execution of any script
#
# Version: 0.53 (2012.06.27)
#

# Part 0 - Introduction
# * read README.txt for product description and general notes
# * this is Installation and Usege, NOT upgrade instaructions
# * for UPGRADE - check UPGRADE.txt if available
# * Next actions in DB should be done by user with DBA role granted or ....

# Part I - create objects in target Oracle DB
# - all data kept per database in present version
# - see also: create\sps_create.sql  
1) create tablespace SPACESTAT
create\cre_tablespace.sql
# tablespace name SPACESTAT is only supported for installation in present version
# but you can move ant segment to any tablespace as you wish
# or wait later version for some customisation

2) create user SPACESTAT identified by ... 
create\cre_user.sql
# quotas and grants also there
# ! note: some permissions a bit too much compared to required set of privilegies
# review the code and set more restrictions yourself or wait next version
# 

3) create tables, indexes, constraints
create\cre_tables.sql
# indexes now kept together with tables in one tablespace
# may be not the best practice, but StatsPack do in the same style :)
# It's a joke. Will be improved in future versions
#

4) create packages
create\cre_packages.sql
# creates 3 procedures
#
5) test it to do some snaps with DBA user or SPACESTAT user
# DBS - segments (in DB)
# DBF - files (in DB)
execute SPACESTAT.SPS_MAKE_SNAP('DBF');
execute SPACESTAT.SPS_MAKE_SNAP('DBS');
#
# or ALL - will make snapshots of all supported types
execute SPACESTAT.SPS_MAKE_SNAP('ALL'); 
#
# do it again to have 2nd snapshots with unique ID 
execute SPACESTAT.SPS_MAKE_SNAP('ALL');

6) check data is collected

set lines 400
set pages 100
select * from SPACESTAT.SPS_SNAPS;
select count(1) from SPACESTAT.SPS_SNAP_DATA;

# Note: sps_snap.sql will to the same

# Part II - setup regular snapshoting

7) Next: we need to schedule regular snapshoting for target DBs
You can schedule it with DB Jobs or Scheduler
# or install 2 scripts and setup in cron
# Ops! Bat-file for Windows is missing, but hope You can write your own.
#

# Install scripts (client) on target host

# create directory for file in any place you wish (path not hard-coded),
# for example
export SOFT_HOME=/u01/app/cominder/product
SOFT_HOME=${SOFT_BASE}/db/space_stat
mkdir -p ${SOFT_HOME}

# place collector scripts to that place
# Note! if you are copying from Windows to UNIX/Linux - use ASCII (Text) mode fo transfer unpacked files
#
# and set permissions 
chmod u+x ${SOFT_HOME}/*.sh
chmod o-rwx ${SOFT_HOME}/*.*
 
ls -l ${SOFT_HOME}
-rwxr-----  1 oracle oinstall 471 Dec 28 13:59 sps_snap.sh
-rw-r-----  1 oracle oinstall 435 Dec 28 13:57 sps_snap.sql

8) Test script is working manaully
${SOFT_BASE}/db/space_stat/sps_snap.sh ORACLE_SID

output should be like this:
SQL>
PL/SQL procedure successfully completed.
  COUNT(1)
----------
         4

-- gather data again, check reports

9) Schedule job in crontab or in DB  for daily execution
just for every DB or make ALL-in-one start script (/u01/app/cominder/product/db/space_stat/do_snap_ALL.sh 1>/u01/app/cominder/LOG/space_stat_ALL.log 2>&1 )
#
# Collect DB segments and files used space statistic
01 01 * * * /u01/app/cominder/product/db/space_stat/sps_snap.sh DBTEST 1>/u01/app/cominder/LOG/space_stat_DBTEST.log 2>&1
03 01 * * * /u01/app/cominder/product/db/space_stat/sps_snap.sh DBPROD 1>/u01/app/cominder/LOG/space_stat_DBPROD.log  2>&1
#

# Part III - generate reports
#
10) Check reports from sql*plus. Reports are in reports directory:
check reports/DIRINFO.txt for details
All reports are safe - running reports do SELECT ... only
So to feel what best suits Your needs just try ALL of them and review output

#

 
