oracle ogg 监控脚本

#!/bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/jdk/bin
export OGG_HOME=/u01/ogg12
export PATH=$OGG_HOME:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
cd $OGG_HOME
flag=0
function send_waring {
flag=$1
err_abended_text=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|grep ABENDED|awk -F ' ' '{print $3,$2}'`
err_stoped_text=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|grep STOPPED|awk -F ' ' '{print $3,$2}'`
err_delay_text=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|gawk -F ':' '{if ($2>=30) print $0}'`
case $flag in
 0)  echo -e "运行正常";;
 1)  echo -e "终止的进程有${err_abended}个\n${err_abended_text}";;
 2)  echo -e "停止的进程有${err_stoped}个\n${err_stoped_text}";;
 3)  echo -e "延迟的进程有${err_delay}个\n${err_delay_text}";;
 *)  echo -e "标志不合法" 
esac
}
function check_status {
err_abended=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|grep ABENDED|wc -l`
err_stoped=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|grep STOPPED|wc -l`
err_delay=`(echo info all;echo exit)|./ggsci|grep -E "EXTRACT|REPLICAT"|awk '{print $4}'|awk -F : '{print $2}'|awk ' {if ($1>=30)  print $1 }'|wc -l`
if [ $(expr $err_abended + $err_stoped + $err_delay) -gt 0 ] ; then 
   if [ ${err_abended} -gt 0 ] ; then
      flag=1
   elif [ ${err_stoped} -gt 0 ] ; then 
      flag=2
   elif [ ${err_delay} -gt 0 ] ; then
        flag=3
   else 
       flag=4
  fi
fi
}

check_status
send_waring $flag 

#date -d today +"%Y-%m-%d %H:%M:%S" 

你可能感兴趣的:(oracle,Linux)