zoukankan      html  css  js  c++  java
  • 一个监控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
  • 相关阅读:
    Binary Search Tree Iterator 解答
    Invert Binary Tree 解答
    Min Stack 解答
    Trapping Raining Water 解答
    Candy 解答
    Jump Game II 解答
    Implement Hash Map Using Primitive Types
    Gas Station 解答
    Bucket Sort
    HashMap 专题
  • 原文地址:https://www.cnblogs.com/peter1994/p/7514671.html
Copyright © 2011-2022 走看看