---- 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]
# ps -ef|grep ORACLE_SID
# check /${ARCHIVE_BASE_DIR}log directory if exists

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 $1 ..."

|
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" 23 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 : This is the sub-program called by alert_master.sh
#Purpose : Send E-Mail notification,if there is an ORA- error in Alert Log
#
SCRIPTDIR=/home/oracle/utility/macro
ORACLE_SID=$1
export ORACLE_SID
if [ -z "$1" ]
  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 [ $chk1 -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 $ct1 - $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" ts-dba@test.com.cn
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" ts-dba@test.com.cn
    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 $1 }' | 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 $0` [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 is 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 > $FILE1;
sleep $SLEEPTIME;
${SCRIPT_DIR}/check_blocker  $ORACLE_SID | grep -v 'DO NOT KILL' | grep KILL > $FILE2;

while read LINE; do
COMPSTR=`echo $LINE | awk '{print $2}'`
if [ `grep $COMPSTR $FILE2 | 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 < $FILE1

shell 2 解析的更多相关文章

  1. [linux] linux shell 将解析完毕的文件备份至其他目录

    #!/bin/bash # #将解析完毕的日志备份到别的目录 # #日志目录 rjPath=`ls /home/bgftp/orj` #当前时间戳 cur=`date +%s` #一小时 chtm=3 ...

  2. shell动态解析sql的binlog

    #!/usr/bin #设置数据库连接 conn='mysql -hhost -Pport -uusername -ppassword' #获取最新的binlog文件 logfile=$($conn ...

  3. Shell命令解析

    1.简单语法: 执行shell:                                sh executeTest.sh puttyy上跑java:                      ...

  4. [svc]entrypoint.sh shell脚本解析

    最近搞influxdb绘图,看到其dockerfile的entry.sh,无奈看的不是很懂. 于是查了下.. docker run 通过传参实现配置文件覆盖 实现启动镜像时候可指定配置文件 如果不指定 ...

  5. shell脚本解析json文件

    安装jq扩展 下载:jq 根据自己系统下载对应的文件 cp jq-linux64 /usr/bin cd /usr/bin mv jq-linux64 jq chmod +x jq 使用方法 假设有个 ...

  6. monkey+shell命令解析总结

    结束monkey方法 Linux下: adb shell top | grep monkey windows下: 1.adb shell top | find "monkey" 5 ...

  7. Linux shell read 解析

    read是一个重要的bash命令,它用于从键盘或标准输入中读取文本,我们可以用read以交互的方式读取来自用户的输入,不过read能做的可远不止这些,当从键盘读取用户输入的时候,只有按下回车键才标志输 ...

  8. shell top解析

    top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按键来不 ...

  9. shell解析命令行的过程以及eval命令

    本文说明的是一条linux命令在执行时大致要经过哪些过程?以及这些过程的大致顺序. 1.1 shell解析命令行 shell读取和执行命令时的大致操作过程如下图: 以执行以下命令为例: echo -e ...

随机推荐

  1. Echarts 的样例

    jsp页面: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8 ...

  2. Django项目开发-小技巧

    当你开发完一个Django项目之后肯定要吧他丢到服务器让跑起来,但是你在自己的环境下安装了好多的包,是不是在服务器中也要一个个的安装了, pip freeze > read.txt #这条命令会 ...

  3. 初步学习C++中的继承关系

    继承机制是面向对象程序设计使代码能够复用的最重要的手段,它同意程序猿在保持原有类特性的基础上进行扩展,添加功能. 这样产生新的类,称派生类.继承呈现了面向对象程序设计的层次结构,体现了由简单到复杂 ...

  4. 【小技能】如何检索苹果APP

    有时候要临时在PC上查询一下苹果APP的信息,但是又没有安装itunes软件,那么你可以在必应里面使用类似如下的语句,例如来搜索“aboboo site:itunes.apple.com”,就可以搜索 ...

  5. 2016/05/25 get和post的区别

    get是从服务器上获取数据,post是向服务器传送数据.   get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,在URL中可以看到.post是通过HTTP ...

  6. tunctl和虚拟网卡

    1 tun/tap驱动 1.1 网卡驱动 同tcp/ip协议栈打交道,接受和发送数据包 1.2 字符驱动 内核和用户态通过字符设备交换数据包. 2 tun虚拟网卡的创建 tunctl -t tun0 ...

  7. Django's CSRF mechanism

    Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this ...

  8. 内存转储文件 Memory.dmp

    https://baike.sogou.com/v63435711.htm?fromTitle=内存转存文件 内存转储是用于系统崩溃时,将内存中的数据转储保存在转储文件中,供给有关人员进行排错分析用途 ...

  9. Filter 详解

    一.Filter简介 Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态 ...

  10. arm位清零bic指令

    (1)指令的语法格式 BIC{<cond>}{S} <Rd>,<Rn>,<shifter_operand> BIC(Bit Clear)位清零指令,将寄 ...