• 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
     
     
  • 相关阅读:
    常用设计模式
    文件上传相关报错: The current request is not a multipart request或is a MultipartResolver configured?
    Intellij IDEA 与 Gitlab 实现代码上传与下载
    Oracle两表关联,只取B表的第一条记录
    notepad++ 调整行间距
    Ubuntu18.04直接安装python3.7或者升级自带的python3.6版本之后导致终端无法打开的解决办法
    黑苹果之DELL台式机安装Mac OS X 10.13.6版本操作系统
    Windows Ping | Tracert 's Bat 脚本并行测试
    centos 7 修改 sshd | 禁止 root 登录及 sshd 端口脚本定义
    C语言中malloc函数的理解
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/10912000.html
Copyright © 2020-2023  润新知