oracle数据库监听监控shell脚本

 

#!/bin/sh
########################Oracle monitor maintenance scripts####################                              
export ORACLE_BASE=/oracle/app
export CRS_HOME=/oracle/crs
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=cicro1
export ORACLE_TERM=xterm
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:$ORACLE_HOME/rdbms/lib:$CRS_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin:$CRS_HOME/bin:/oracle/app/product/10.2/OPatch:/usr/local/bin:/usr/ccs/bin:$PATH
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib/$CLASSPATH:$ORACLE_HOME/network/jlib:$CRS_HOME/jlib
export NLS_LANG=american_america.ZHS16GBK
export TEMP=/oracle/tmp
export TMP=/oracle/tmp

export DATE=`date +%Y%m%d_%H%M%S`
export DATELOG=`date +%Y%m%d`
export LSNRCTLOG=/oracle/cmd/lsnrctl$DATELOG.log
export ORACMDHOME=/oracle/app/product/10.2.0/bin

echo "" >>$LSNRCTLOG 
echo "$DATE ------- Oracle Lisenter monitor is started ------ " >>$LSNRCTLOG
cd $ORACMDHOME
export LSNSTATUS=`lsnrctl status |grep "no listener"|wc -l`

if [ "$LSNSTATUS" = "0" ]; then
      echo "$DATE Listener is running properly !">>$LSNRCTLOG
else
      echo "$DATE Listening to problems, is trying to restart ...... ">>$LSNRCTLOG
            lsnrctl start
      sleep 10 

export LSNSTATUS=`lsnrctl status |grep "no listener"|wc -l`
export LSNSTARTIME=`lsnrctl status |grep "Start Date"`

      if [ "$LSNSTATUS" = "0" ]; then
         echo "The Listener started! " >> $LSNRCTLOG
         echo "$LSNSTARTIME Lsnrctl. " >>$LSNRCTLOG
      else
         echo "${DATE} The listener can not start !  " >>$LSNRCTLOG
      fi
fi

你可能感兴趣的:(Linux shell,shell脚本,oracle shell,oracle监听shell)