----Shell 3
/home/oracle/utility/macro/call_autopurge_arch.sh
Description:call Purge Archive log file job
# Syntax:autopurge_arch.sh [Oracle_sid] [archived base dir] [#hours kept]
#
Script_dir=/home/oracle/utility/macro
#${script_dir}/autopurge_archlog.sh Ngende/ngdedb 6
#add in 20160901
${script_dir}/autopurge_archlog.sh Oasprod/oasprod 24
|
More ${script_dir}/autopurge_archlog.sh
#!/usr/bin/sh
#
# description:purging archive log files stored in archive log mount point ${db_base_dir}log
#
#
# Syntax:autopurge_archlog.sh [Oracle_sid] [archived base dir] [#days kept]
#
#
Path=/usr/local/bin:/usr/bin: $PATH
echo "------------------------------------------------------------------------"
Script_dir=/home/oracle/utility/macro
Up_flag= ' ${script_dir}/chkdbup.sh ${1} '
#echo $dbname "" $up _flag
If [${up_flag}-eq 0]; Then
Export oracle_sid=$1
Export Oraenv_ask=no
. Oraenv >/dev/null
Export oraenv_ask=
Db_base_dir=$2;export Db_base_dir
keep_hours=$3; Export Keep_hours
purge_arch=/home/oracle/utility/macro/purge_file.sh; Export Purge_arch
Arch_dir= "${db_base_dir}log"; Export Arch_dir
Sqlplus-s "/As SYSDBA" @${script_dir}/get_define_arclog.sql ${keep_hours}
arch_log_pattern= ' sed-e ' s///g '/tmp/get_define_arclog.lst|tail-n 1 '. gz;
Export Arch_log_pattern;
If [-f ${arch_log_pattern}]
Then
echo "Define archive log had gzip"
Else
arch_log_pattern= ' sed-e ' s///g '/tmp/get_define_arclog.lst|tail-n 1 '
If [-f ${arch_log_pattern}]
Then
echo "Define archive log don ' t gzip"
Else
echo "Not need house keeping"
Exit 0
Fi
Fi
echo ${arch_dir} ${arch_log_pattern}
Find ${arch_dir}! -newer ${arch_log_pattern}-exec ${purge_arch} {} \;
Else
echo "' Date ': Instance ${1} not running on ' hostname ' ..."
Fi
|
more/home/oracle/utility/macro/purge_file.sh
#!/usr/bin/sh
echo "Purging $ ..."
|
More ${script_dir}/get_define_arclog.sql
Set echo off heading off Veri off feedback off
Spool/tmp/get_define_arclog.lst
Select Trim (name) from V$archived_log where First_time = (select Max (first_time) from V$archived_log
where First_time < (Sysdate-&1/24))
/
Spool off
Exit
--shell 4
vi/home/oracle/utility/macro/alert_master.sh
"/home/oracle/utility/macro/alert_master.sh" lines, 451 characters
#!/bin/ksh
#Program: alert_master.sh
#Author: David
#Document: This is the main program,checks alert for all instances
#
#SCRIPTLOC =/cluster/dhp/oracle/erp_scripts/alert_scripts
Scriptloc=/home/oracle/utility/macro
Export Scriptloc
For i in ' Cat/etc/oratab |grep-v "^[#]" |cut-d:-f1 '
Do
ora_stat= ' ps-ef|grep-v grep|grep ora_smon_$i|wc-l '
ora_chk= ' Expr $ora _stat '
If [$ora _chk-eq 1]
Then
$SCRIPTLOC/alert.sh $i
Fi
Done
|
More alert.sh
#!/bin/ksh
#Program: alert.sh
#Author: David
#Document: The Sub-program called by alert_master.sh
#Purpose: Send e-mail notification,if There is a ora-error in Alert Log
#
Scriptdir=/home/oracle/utility/macro
Oracle_sid=$1
Export Oracle_sid
If [-Z]
Then
echo "Usage:alert.sh"
Exit 99
Fi
stat= ' ps-ef|grep-v grep|grep ora_smon_$1|wc-l '
ora_stat= ' Expr $stat '
If [$ora _stat-eq 0]
Then
Exit 0
Fi
Oracle_home= ' Cat/etc/oratab|grep-v "^[#]" |grep $ORACLE _sid|cut-d:-f2 '
Export Oracle_home
Export path= $ORACLE _home/bin: $PATH
$ORACLE _home/bin/sqlplus-s '/as SYSDBA ' <<!
@/home/oracle/utility/macro/get_dict_parm
Exit
!
alrt_chk= ' Cat/home/oracle/utility/macro/alert_$1_dir.log|grep? | Wc-l '
alrt_stat= ' Expr $ALRT _chk '
If [$ALRT _stat-eq 1]
Then
alert_dir= $ORACLE _home/rdbms/log
Else
Alert_dir= ' Cat/home/oracle/utility/macro/alert_$1_dir.log '
Fi
Export Alert_dir
CD $SCRIPTDIR
If [-F $SCRIPTDIR/cntfile_$1.log]
Then
Chk= ' Cat $SCRIPTDIR/cntfile_$1.log|wc-l '
chk1= ' Expr $chk '
If [$chk 1-GT 0]
Then
Cat $SCRIPTDIR/cntfile_$1.log|read num
Else
Num=0
Fi
Else
Touch $SCRIPTDIR/cntfile_$1.log
Num=0
Fi
If [$num-GT 0]
Then
CD $ALERT _dir
Cat Alert_${oracle_sid}.log |wc-l |read ct1
sz= ' expr $ct 1-$num '
If [$sz-eq 0]
Then
Exit
Fi
CD $ALERT _dir
Cat Alert_${oracle_sid}.log |tail-$sz |grep ora-|\
Grep-v ora-279|\
Grep-v ora-000060|\
Grep-v ora-00060|\
Grep-v 308|\
Grep-v 3217|\
Cat >/tmp/alerterr_$1.log 2> $SCRIPTDIR/error_$1_.log
Ora_cnt= ' Cat/tmp/alerterr_$1.log|wc-l '
ora_num= ' Expr $ora _cnt '
If [$ora _NUM-GT 0]
Then
Cat/tmp/alerterr_$1.log|/usr/bin/mailx-s "Alert log Errors for the database $ORACLE _sid" [email protected]
Fi
Cat Alert_${oracle_sid}.log |wc-l|read CNT
echo $cnt > $SCRIPTDIR/cntfile_$1.log
Exit
Else
CD $ALERT _dir
Cat Alert_${oracle_sid}.log | grep ora-|cat >/tmp/alerterr_$1.log
Ora_cnt= ' Cat/tmp/alerterr_$1.log|wc-l '
ora_num= ' Expr $ora _cnt '
If [$ora _NUM-GT 0]
Then
Cat/tmp/alerterr_$1.log|/usr/bin/mailx-s "Alert log Errors for the database $ORACLE _sid" [email protected]
Fi
Cat Alert_${oracle_sid}.log | Wc-l |read CNT
echo $cnt > $SCRIPTDIR/cntfile_$1.log
Fi
---Shell 5
/home/oracle/utility/macro/purge_trc_files.sh
#!/bin/ksh
#
# Description:purge useless files
# Syntax:purge_trc_files.sh
#
# date:22-jul-2003
#
dt= ' Date ' +%y%m%d%h%m '
Export path= $PATH:/usr/local/bin
Export Root_dir=/home/oracle
Export script_dir= $ROOT _dir/utility/macro
Export logfile_dir= $ROOT _dir/utility/log
Export tmp_dir= $ROOT _dir/utility/tmp
logfile= $LOGFILE _dir/purge_trc_files.log
Dblist=${script_dir}/pfdblist
Export Oracle_sid=xprprod
Export Oraenv_ask=no
. Oraenv >/dev/null
Export oraenv_ask=
echo "******" ' Date ' >> $LOGFILE
Grep-v ' ^# ' $DBLIST | awk ' {print '} ' | Sort-u | While Read dbname
Do
# 1. Check whether DB is up and running on server
Up_flag= ' ${script_dir}/chkdbup.sh ${dbname} '
# echo $dbname "" $up _flag
If [${up_flag}-eq 0]; Then
echo "Starting purging Files for ${dbname}" ' Date ' "\ n" >> $LOGFILE
# 2. Purge FIles
Grep-v ' ^# ' $DBLIST | Grep-i ${dbname} | While read dbname Pfdir pfext pf_retention
Do
Find $pfdir-name \*.trc-mtime +${pf_retention}-exec ls-lrt {} \; 1>> ${logfile}
Find $pfdir-name \*.trc-mtime +${pf_retention}-exec rm {} \; 1>> ${logfile} 2>&1
Find $pfdir-name \*.trm-mtime +${pf_retention}-exec ls-lrt {} \; 1>> ${logfile}
Find $pfdir-name \*.trm-mtime +${pf_retention}-exec rm {} \; 1>> ${logfile} 2>&1
Find $pfdir-name \*.aud-mtime +${pf_retention}-exec ls-lrt {} \; 1>> ${logfile}
Find $pfdir-name \*.aud-mtime +${pf_retention}-exec rm {} \; 1>> ${logfile} 2>&1
Find $pfdir-name \*_arc\*.trc-mtime +${pf_retention}-exec rm {} \; 1>> ${logfile} 2>&1
Done
Fi
Done
echo "****** completed at:" ' Date ' "\ n" >> $LOGFILE
|
More ${script_dir}/pfdblist
# DB list for purging files
Bizprod/bizlinkdb/adump. AUD 2
Bizprod/bizlinkdb/diag/rdbms/bizprod/bizprod/trace. TRC 2
Bizprod/bizlinkdb/diag/rdbms/bizprod/bizprod/trace. TRM 2
Centrprod/centrproddb/diag/rdbms/centrprod/centrprod/trace. TRC 4
Centrprod/centrproddb/diag/rdbms/centrprod/centrprod/trace. TRM 4
Centrprod/centrproddb/adump. AUD 2
~
----Shell 6~
~more/home/oracle/utility/blocker/detect_blocker.sh
Echo_usage ()
{
echo "Usage: ' basename $ ' [SID] <sleep time>"
Echo $*
echo "Cause:no SID or Database is not running on server"
Exit 0
}
If [$#-lt 2]
Then
Echo_usage
Fi
#
# See whether the DB was actually running on this machine or not
#
Export oracle_sid=$1
Ps-ef | Grep-v grep | grep Ora_smon_${oracle_sid} >/dev/null
If [$?-ne 0]
Then
Echo_usage
Fi
Export path= $PATH:/usr/local/bin
Export Oraenv_ask=no
. Oraenv >/dev/null
Export oraenv_ask=
Export Root_dir=/home/oracle
Export script_dir= $ROOT _dir/utility/blocker
Export logfile_dir= $ROOT _dir/utility/log
Export tmp_dir= $ROOT _dir/utility/tmp
ext= "' Date ' +%y%m%d%h%m%s '"
FILE1=/TMP/DETECT_BLOCKER1.${ORACLE_SID}. $EXT
FILE2=/TMP/DETECT_BLOCKER2.${ORACLE_SID}. $EXT
Opcmsgcmd=/opt/ov/bin/opc/opcmsg
Sleeptime=$2
${script_dir}/check_blocker $ORACLE _sid | Grep-v ' do not KILL ' | grep KILL > $FILE 1;
Sleep $SLEEPTIME;
${script_dir}/check_blocker $ORACLE _sid | Grep-v ' do not KILL ' | grep KILL > $FILE 2;
while read line; Do
Compstr= ' echo $LINE | awk ' {print $} '
If [' grep $COMPSTR $FILE 2 | wc-l '-eq 1]; Then
echo ' blocker detected as: ';
Echo
Echo ' Oracle Session id/serial#: ' $COMPSTR
Ovomsg= ' DB: ' ${oracle_sid} '-blocker detected ORACLE Session id/serial#: ' ${compstr} ', please keep monitoring system And Donnot kill the blocker until warning messages is
Exceeding at least 3 times with the same blocker. '
Echo $OVOMSG
$OPCMSGCMD s=critical a=db o=blocker msg_grp=db msg_t= "${ovomsg}"
Fi
Done < $FILE 1
Shell 2 parsing