shell 2 解析
---- 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 解析的更多相关文章
- [linux] linux shell 将解析完毕的文件备份至其他目录
#!/bin/bash # #将解析完毕的日志备份到别的目录 # #日志目录 rjPath=`ls /home/bgftp/orj` #当前时间戳 cur=`date +%s` #一小时 chtm=3 ...
- shell动态解析sql的binlog
#!/usr/bin #设置数据库连接 conn='mysql -hhost -Pport -uusername -ppassword' #获取最新的binlog文件 logfile=$($conn ...
- Shell命令解析
1.简单语法: 执行shell: sh executeTest.sh puttyy上跑java: ...
- [svc]entrypoint.sh shell脚本解析
最近搞influxdb绘图,看到其dockerfile的entry.sh,无奈看的不是很懂. 于是查了下.. docker run 通过传参实现配置文件覆盖 实现启动镜像时候可指定配置文件 如果不指定 ...
- shell脚本解析json文件
安装jq扩展 下载:jq 根据自己系统下载对应的文件 cp jq-linux64 /usr/bin cd /usr/bin mv jq-linux64 jq chmod +x jq 使用方法 假设有个 ...
- monkey+shell命令解析总结
结束monkey方法 Linux下: adb shell top | grep monkey windows下: 1.adb shell top | find "monkey" 5 ...
- Linux shell read 解析
read是一个重要的bash命令,它用于从键盘或标准输入中读取文本,我们可以用read以交互的方式读取来自用户的输入,不过read能做的可远不止这些,当从键盘读取用户输入的时候,只有按下回车键才标志输 ...
- shell top解析
top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按键来不 ...
- shell解析命令行的过程以及eval命令
本文说明的是一条linux命令在执行时大致要经过哪些过程?以及这些过程的大致顺序. 1.1 shell解析命令行 shell读取和执行命令时的大致操作过程如下图: 以执行以下命令为例: echo -e ...
随机推荐
- SDUTOJ 2475 Power Strings
<pre class="cpp" name="code">#include<iostream> #include<stdio.h& ...
- FZU 2150 Fire Game (暴力BFS)
[题目链接]click here~~ [题目大意]: 两个熊孩子要把一个正方形上的草都给烧掉,他俩同一时候放火烧.烧第一块的时候是不花时间的.每一块着火的都能够在下一秒烧向上下左右四块#代表草地,.代 ...
- Robot Framework操作
Robot Framework 介绍 RobotFramework是一款基于python的开源自动化测试框架,遵守Apache License 2.0协议,在此协议下所有人都可以免费开发和使用.因为R ...
- 【转】PLSQL_标准删除的方式Delete/Drop/Truncate区别和比较
- 修改linux环境变量配置文件
发现error ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost) ...
- SpringMVC_基本配置 --跟海涛学SpringMVC(和自己在项目中的实际使用的对比)
☆依赖jar包: 1.Spring框架jar 包: 为了简单,将spring-framework-3.1.1.RELEASE-with-docs.zip/dist/下的所有jar包拷贝到项目的WEB- ...
- Java中会存在内存泄露吗?请简单描述。
本文转载自:Java中会存在内存泄漏吗,请简单描述 会.java导致内存泄露的原因很明确:长生命周期的对象持有短生命周期对象的引用就很可能发生内存泄露,尽管短生命周期对象已经不再需要,但是因为长生命周 ...
- Lightoj 1009 - Back to Underworld
1009 - Back to Underworld PDF (English) Statistics Forum Time Limit: 4 second(s) Memory Limit: 32 ...
- 《CMake实践》笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE【转】
本文转载自:http://www.cnblogs.com/52php/p/5681745.html 前言: 开发了5,6年的时间,如果没有KDE4,也许不会有人或者Linux发行版本重视cmake,因 ...
- mac系统下安装mysql步骤
1.下载mysql-5.7.13-osx10.11-x86_64.dmg安装包,并点击dmg安装包进行安装 2.安装完成后弹出如以下提示信息: 2016-06-23T01:14:48.649253Z ...