【shell】根據檔案時間有無更新進行報警

ringoo_ming發表於2017-03-17

  1. !/bin/sh
  2. export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
  3. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/oracle/product/ora10/lib
  4. export TNS_ADMIN=/data/oracle/product/ora10/network/admin
  5. export ORACLE_HOME=/data/oracle/product/ora10
  6. export ORACLE_SID=dbmisc
  7. LOG="/data/oracle/product/ora10/network/log/listener.log"
  8. DIR="/home/shell/hostmonitor/logs"
  9. MAILLIST="pso@datou.com"
  10. LOGDATE=`date +%s -r $LOG`
  11. CURDATE=`date +%s`
  12. COUNT=`expr $CURDATE - $LOGDATE`
  13. if [ $COUNT -ge 300 ];then
  14. cat << EOF > $DIR/listener.txt
  15. #ps -ef|grep oracle|grep LISTENER
  16. #lsnrctl start
  17. EOF
  18. mailx -s "####### 192.168.1.208 dbmisc listener alert #######" $MAILLIST < $DIR/listener.txt
  19. $ORACLE_HOME/bin/sqlplus /nolog << EOF
  20. connect dtuser_smsold/datuu
  21. insert into dt_smssend (numsmssendid,vc2enabledflag,datcreation,vc2to,vc2content,vc2url,vc2source) values(dtseq_smssend.nextval,'Y',sysdate,'13691343631','192.168.1.208 dbmisc listener have problem!','','');
  22. insert into dt_smssend (numsmssendid,vc2enabledflag,datcreation,vc2to,vc2content,vc2url,vc2source) values(dtseq_smssend.nextval,'Y',sysdate,'13810607733','192.168.1.208 dbmisc listener have problem!','','');
  23. exit;
  24. EOF
  25. fi

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

相關文章