• 一个监控oracle数据库某个字段值变化并发送邮件报警的脚本


      talk is cheap,here is the code:

    #!/bin/sh
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/client_1/
    export PATH=$PATH:$ORACLE_HOME/bin
    export base_path=/home/peteryrcc/code/database
    
    sqlplus account/'password'@10.75.65.142:1521/database name <<EOF
    spool /home/peteryrcc/code/database/current_dmtc.log
    @/home/peteryrcc/code/database/dmtc_monitoring.sql
    spool off
    EOF
    
    export current=$base_path/current_dmtc.log
    export historical=$base_path/historical_dmtc.log
    
    grep 'NEW' $current>/dev/null
    if [ $? -ne 0 ];then
            grep 'NEW' $historical>/dev/null
            if [ $? -ne 0 ];then
                    echo 'no found all the time'
            else
                    cat $current>$historical
                    echo $(date)-------"no found !">>$base_path/dmtc_monitoring.log
                    echo 'the DMTC status has been turn to completed, please perform the update'|mail -s "DOCTOR_MODEL_TYPE_CODE issue! " peteryang.rcc@cn.luxottica.com Amy.Xiong@cn.luxottica.com
    
            fi
    else
            grep 'NEW' $historical>/dev/null
            if [ $? -eq 0 ];then
                    echo 'found all the time'
            else
                    cat $current>$historical
                    echo $(date)-------"found DMTC=11">>$base_path/dmtc_monitoring.log
                    cat $current|grep -v SQL|mail -s "DOCTOR_MODEL_TYPE_CODE issue! " peteryang.rcc@cn.luxottica.com Amy.Xiong@cn.luxottica.com
            fi
    fi
  • 相关阅读:
    C语言II博客作业03
    C语言II博客作业02
    C语言II博客作业01
    学期总结
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言|博客作业05
    C语言I博客作业04
    【lhyaaa】2020深圳大湾区比赛总结
  • 原文地址:https://www.cnblogs.com/peter1994/p/7514671.html
Copyright © 2020-2023  润新知