Oracle shell监控小脚本

前端之家收集整理的这篇文章主要介绍了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,$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,$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,$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,$h!" else echo "OK" fi

猜你在找的Oracle相关文章