zoukankan      html  css  js  c++  java
  • Oracle shell监控小脚本

    cat dba_cpu_monitor.sh   
    ##CPU Monitor
    h=`hostname`
    cpu_used=`top -b -d 1 -n 2 | grep Cpu | awk 'NR>1'`
    user_cpu_used=`echo $cpu_used|awk '{print $2}'`
    sys_cpu_used=`echo $cpu_used|awk '{print $4}'`
    io_cpu_used=`echo $cpu_used|awk '{print $10}'`
    idle_cpu=`echo $cpu_used|awk '{print $8}'`
    b=50
    c=$(echo "$user_cpu_used >$b"|bc)
    if [ $c -eq 1 ]
    then
     # echo "Please check SQL!"
      echo "CPU Used $user_cpu_used% Over 25%,Please Check,$h!"
    else
    echo "OK"
    fi
     
     
    cat dba_oracle_listener_monitor.sh
    #Oracle listener check
    h=`hostname`
    v_l=`ps -ef|grep ora|grep LISTENER|grep -v grep|awk '{print $2}'`
    if [ ! -n $v_l ]; then
      #echo "IS Wrong!"
      echo "Oracle LISTENER is Down,Please Check,$h!"
    else
      #echo "Listener Status IS OK!"
      echo "OK"
    fi
     
     
    cat dba_oracle_status_monitor.sh
    #Oracle status check
    v_s=`ps -ef|grep ora|grep ora_smon|grep -v grep|awk '{print $2}'`
    h=`hostname`
    if [ ! -n $v_s ]; then
      #echo "IS Wrong!"
      echo "Oracle DB is Down,Please Check,$h!"
    else
      #echo "Oracle Status IS OK!"
      echo "OK"
    fi
     
     
    cat dba_session_monitor.sh
    source ~/.bash_profile
    ##Oracle session
    h=`hostname`
    k="set heading off feedback off pagesize 0 verify off echo off"
    t="v$session"
    v_session=`sqlplus -s dbadmin/QazWsx12  << EOF
    $k
    SELECT count(1) FROM $t s where s.STATUS='ACTIVE' and s.TYPE='USER';
    EOF`
    #echo v_session
    if [ $v_session -gt 15 ]
    then
      echo "Oracle Active session $v_session Over 15,Please Check,$h!"
    else
    echo "OK"
    fi
     
     
    cat dba_tablespace_monitor.sh
    source ~/.bash_profile
    ##Oracle tablesapce
    h=`hostname`
    k="set heading off feedback off pagesize 0 verify off echo off"
    t="dba_users"
    v_tab_used=`sqlplus -s dbadmin/QazWsx12  << EOF
    $k
    select * from (
    select
    case
    when s.USED_PERCENT<95 then 'OK'
      else 'Tablespace '||s.TABLESPACE_NAME||' Used '||round(s.USED_PERCENT,2)||'%,'||'Please Check!'
    end status
    from
    dba_tablespace_usage_metrics s where s.TABLESPACE_NAME in ('PAYIDX','USERS','UNDOTBS1')) a where status !='OK';
    EOF`
    #echo v_tab_used
    if [ -n "$v_tab_used" ]
    then
      echo "$v_tab_used","$h"
    else
      echo "OK"
    fi
     
     
    cat dba_user_lock_monitor.sh
    source ~/.bash_profile
    ##Oracle session
    h=`hostname`
    k="set heading off feedback off pagesize 0 verify off echo off"
    t="dba_users"
    v_user_lock=`sqlplus -s dbadmin/QazWsx12  << EOF
    $k
    SELECT s.username,s.account_status FROM $t s where s.username in ('BOSS','ISMP','TEMP_DSF','PAY','ACCOUNT','SETTLE','TESTUSER') and s.account_status !='OPEN';
    EOF`
    #echo $v_user_lock
    if [ -n "$v_user_lock" ]
    then
      echo "$v_user_lock ,Please Check,$h!"
    else
    echo "OK"
    fi
     
     
  • 相关阅读:
    流行-Manifold学习理解与应用
    狠心奶奶自断亲情,28年后孙女拒绝相见:人有没有不原谅的权利?
    学术论文常用词汇总结(待更新)
    机动车驾驶(2)--- 老司机经验
    关于MySQL数据导出导入
    php5.6-lumen与php5.6-phalcon性能对比
    win7(64bit)+python3.5+pyinstaller3.2安装和测试
    WARNING: Can not get binary dependencies for file...
    一些不错的计算机书籍
    PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/10912000.html
Copyright © 2011-2022 走看看