Last active
July 22, 2019 14:56
-
-
Save achampav/5b858c05962d86c4d6d80e9f814fa408 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Récupération d'AWR par lots (bash) | |
#!/bin/bash | |
# Pour IBM AIX : !/usr/bin/bash | |
############################################################################### | |
# @(#) Script : all_awr.sh | |
# @(#) Licence : GNU GPL | |
# @(#) Autrice : Alexandra Champavert | |
# @(#) Date creation : 11/03/2016 | |
# @(#) Date modification : 22/07/2019 | |
# @(#) Version : 1.01 | |
# @(#) Versions : | |
# @(#) 0.90 : 11/03/2016 ACH : Version initiale | |
# @(#) 1.00 : 16/03/2016 ACH : Test parametres, ajout liste instances, ajout oraenv | |
# @(#) 1.01 : 22/07/2019 ACH : Correction bug parametre 3 text/html | |
# @(#) Parametres : | |
# @(#) ${1} : Date de debut au format JJ-MM-AAAA | |
# @(#) ${2} : Date de fin au format JJ-MM-AAAA | |
# @(#) ${3} : text/html | |
# @(#) ${4} : Liste des instances a parcourir entre double-cotes et separees par des espaces. Ex : "INSTA1 INSTB2 INSTC0" | |
# | |
# @(#) Utilisation : | |
# @(#) Extraction des rapports AWR d'une liste d'instances avec creation d'un sous-repertoire par instance. | |
############################################################################### | |
if [ $# -ne 4 ] | |
then | |
echo "ERREUR - nombre d'argument" | |
echo "USAGE : $0 <Date debut> <Date fin> <Liste instances entre double-cotes separees par des espaces>" | |
exit 2 | |
fi | |
for i in ${4} | |
do | |
export ORACLE_SID=${i} | |
ORAENV_ASK=NO | |
. oraenv | |
min_snap=` | |
export ORACLE_SID=${i} | |
sqlplus -S /nolog<<ENDSQL | |
connect / as sysdba | |
set echo off | |
set head off | |
set trimspool on | |
set pagesize 0 | |
set linesize 100 | |
ttitle off | |
btitle off | |
set verify off | |
set feedback off | |
select min(snap_id) from dba_hist_snapshot where begin_interval_time >= to_date('${1} 00:00:00','DD-MM-YYYY HH24:MI:SS'); | |
exit | |
ENDSQL` | |
max_snap=` | |
export ORACLE_SID=${i} | |
sqlplus -S /nolog<<ENDSQL | |
connect / as sysdba | |
set echo off | |
set head off | |
set trimspool on | |
set pagesize 0 | |
set linesize 100 | |
ttitle off | |
btitle off | |
set verify off | |
set feedback off | |
select max(snap_id) from dba_hist_snapshot where begin_interval_time <= to_date('${2} 23:59:59','DD-MM-YYYY HH24:MI:SS'); | |
exit | |
ENDSQL` | |
snap_curr=${min_snap} | |
snap_stop=${max_snap} | |
list_snaps=` | |
export ORACLE_SID=${i} | |
sqlplus -S /nolog<<ENDSQL | |
connect / as sysdba | |
set echo off | |
set head off | |
set trimspool on | |
set pagesize 0 | |
set linesize 100 | |
ttitle off | |
btitle off | |
set verify off | |
set feedback off | |
select snap_id from dba_hist_snapshot where snap_id between ${min_snap} and ${max_snap} order by snap_id; | |
exit | |
ENDSQL` | |
debut=1 | |
echo ${list_snaps} | |
mkdir -p ${i} | |
if [ "${3}" = "text" ] | |
then | |
extension=txt | |
else | |
extension=html | |
fi | |
for j in ${list_snaps} | |
do | |
snap_next=${j} | |
if [ ${debut} -eq 0 ] | |
then | |
psc=`echo ${snap_curr}|awk '{printf("%05d",$1);}'` | |
psn=`echo ${snap_next}|awk '{printf("%05d",$1);}'` | |
sqlplus /nolog<<ENDSQL | |
connect / as sysdba | |
define begin_snap=${snap_curr} | |
define end_snap=${snap_next} | |
define report_name=${ORACLE_SID}/awr_${ORACLE_SID}_${psc}_${psn}.${extension} | |
define num_days=1000 | |
define report_type=${3} | |
@@?/rdbms/admin/awrrpt.sql | |
ENDSQL | |
fi | |
debut=0 | |
snap_curr=${j} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment