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 ...
随机推荐
- 【C】字符串,字符和字节(C与指针第9章)
C语言没有一种显式的数据类型是字符串的. C语言存储字符串:字符串常量(不能改动).字符数组或动态分配的内存(能够改动) *************************************** ...
- 深度学习笔记之基于R-CNN的物体检测
不多说,直接上干货! 基于R-CNN的物体检测 原文地址:http://blog.csdn.net/hjimce/article/details/50187029 作者:hjimce 一.相关理论 本 ...
- js实现replaceAll功能
js中没有原生的replaceAll 方法. function replaceAll(str , replaceKey , replaceVal){ var reg = new RegExp(repl ...
- my.cnf配置详解[转载]
先粘贴一份mac下的mysql5.6.22的配置文件 # Example MySQL config file for medium systems. # # This is for a system ...
- ZFIND_EXIT_BADI
*&---------------------------------------------------------------------* *& Report ZFIND_EX ...
- 设计模式-(8)外观(swift版)
一,概念 为子系统中的一组接口提供一个统一的接口.外观模式定义了一个更高层次的接口,这个接口使得这一子系统更加容易使用. 二,结构图 (1)SubSystem子系统类:每个子系统定义了相关功能和模块的 ...
- [RK3288][Android6.0] 关于uboot中logo相关知识点小结【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/76256224 Platform: Rockchip OS: Android 6.0 Kern ...
- regular expression 在线检测的网站
http://regexone.com/ 学习网站 http://regexone.com/lesson/optional_characters? http://regexone.com/less ...
- codeforces 686D D. Kay and Snowflake(dfs)
题目链接: D. Kay and Snowflake time limit per test 3 seconds memory limit per test 256 megabytes input s ...
- 整型变量修饰符,char类型数据存储原理,字节数,
//------------------整型变量修饰符 修饰符(int short long longlong signed unsigned)所有修饰符都是用来修整形 int 4short %hd ...