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
  • 相关阅读:
    人生几宝
    sleep() 和 wait() 有什么区别?
    abstract class和interface有什么区别?
    谈谈final, finally, finalize的区别
    字符串转码【String.getBytes()和new String()】
    Redis中文API地址
    java之ibatis数据缓存
    ibatis的缓存机制
    mysql|表row_format的静态与动态,Compact
    Tesseract ocr 3.02学习记录一
  • 原文地址:https://www.cnblogs.com/peter1994/p/7514671.html
Copyright © 2011-2022 走看看