listener監聽監控指令碼

lusklusklusk發表於2017-05-25
以下兩個指令碼都是可以的,但是前提是指令碼儲存的文字的名稱不能含有lsnr,因為ps -ef|grep lsnr|grep -v grep匹配了指令碼名字


#!/bin/ksh
       ps -ef|grep lsnr|grep -v grep>/dev/null
        if [ $? -eq 0 ]; then
              exit
        else
              echo `date`>/tmp/dsklog.lsnrctl
              echo " The listener is down on 10.98.20.122">>/tmp/dsklog.lsnrctl
              lsnrctl start>>/tmp/dsklog.lsnrctl
              cat /tmp/dsklog.lsnrctl | /usr/local/bin/mailx    -s "listener on 10.98.20.122 is down"  luk.luk@chinadba.cn
        fi





#!/bin/ksh
lsnr_flag=`ps -ef|grep lsnr|grep -v grep`
        if [ -z "$lsnr_flag" ]; then
              echo `date`>/tmp/dsklog.lsnrctl
              echo " The listener is down on 10.98.20.122">>/tmp/dsklog.lsnrctl
              lsnrctl start>>/tmp/dsklog.lsnrctl
              cat /tmp/dsklog.lsnrctl | /usr/local/bin/mailx    -s "listener on 10.98.20.122 is down"  luk.luk@chinadba.cn
        fi

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2139885/,如需轉載,請註明出處,否則將追究法律責任。

相關文章