注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

涅槃

文档收藏

 
 
 

日志

 
 
 
 

shell处理alert日志  

2012-03-21 11:46:58|  分类: shell编程实例 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
#!/usr/bin/ksh
export LANG=en
 
sqlplus -s user/passwd <<!>/dev/null
set echo on
spool tmp/sqlplus.txt
col name format a20
col value format a35
select name,value from v\$parameter where name='background_dump_dest';
spool off
exit
!
 
alert_path_num=$(grep -n "background_dump_dest" tmp/sqlplus.txt |awk -F":" '{print $1}')
alert_path=$(cat tmp/sqlplus.txt |sed -n "${alert_path_num}p" | awk -F" " '{print $2}')
 
first_day=`cat tmp/first_day.tmp`
last_day=$(date|cut -c 1-10).*$(date +%Y)
echo $last_day > tmp/first_day.tmp
 
first_num=$(grep -n "$first_day" $alert_path/alert_$ORACLE_SID.log |head -1|awk -F":" '{print $1}')
if [ -z "$first_num" ]; then
first_num=0
fi
last_num=$(grep -n "$last_day" $alert_path/alert_$ORACLE_SID.log |tail -1|awk -F":" '{print $1}')
 
point=1
export=$point
 
echo "########################## checking alert_log start $first_day ########################## "
 
sed -n "${first_num},${last_num}p" $alert_path/alert_$ORACLE_SID.log > tmp/trunc_alert
cat tmp/trunc_alert|grep ORA-|while read line
do
   line=$(echo "$line"|sed -e 's/\[/\\[/g;s/\]/\\]/g')
   time=$(grep -n "$line" tmp/trunc_alert | awk -F':' '{print $1}'|wc -l)
 
if [ "$time" -ge 1 ]
then
   num=$(grep -n "$line" tmp/trunc_alert|awk -F':' '{print $1}'|tail -1)
   #echo $num
   front_num=$((num-3))
   back_num=$((num+9))
 
   echo "++++++++++++++++++$point++++++++++++++++++++"
    sed -n "${front_num},${back_num}p" tmp/trunc_alert
   echo "++++++++++++++++++$point-End++++++++++++++++"
   point=$((point+1))
 
   flag=1
else
     if [ -z "$time" ]
     then
     flag=0
     fi
fi
done
 
#rm tmp/trunc_alert
 
if [ " $flag " -eq 0 ]
   then
   echo "No errors in $day !"
fi
echo "########################## checking alert_log end $last_day########################## "
 
 
 
 

检查结果

########################## checking alert_log start Fri Jan 27.*2012 ##########################
++++++++++++++++++1++++++++++++++++++++
  Current log# 3 seq# 918 mem# 0: /opt/oracle/oradata/orcl/mcrm/redo03.log
Tue Jan 31 22:00:22 2012
Errors in file /opt/oracle/admin/mcrm/bdump/mcrm_j001_23329.trc:
ORA-01114: IO error writing block to file 201 (block # 550944)
ORA-27072: File I/O error
Linux-x86_64 Error: 28: No space left on device
Additional information: 4
Additional information: 550944
Additional information: -1
ORA-01114: IO error writing block to file 201 (block # 550922)
ORA-27072: File I/O error
Additional information: 4
Additional information: 550922
++++++++++++++++++1-End++++++++++++++++
++++++++++++++++++2++++++++++++++++++++
Additional information: 550944
Additional information: -1
ORA-01114: IO error writing block to file 201 (block # 550922)
ORA-27072: File I/O error
Additional information: 4
Additional information: 550922
Additional information: 114688
Wed Feb  1 07:24:02 2012
Thread 1 advanced to log sequence 919 (LGWR switch)
  Current log# 1 seq# 919 mem# 0: /opt/oracle/oradata/orcl/mcrm/redo01.log
Wed Feb  1 07:24:02 2012
Errors in file /opt/oracle/admin/mcrm/bdump/mcrm_arc1_3624.trc:
ORA-19504: failed to create file "/opt/oracle/oradata/archivelog/1_918_741262746.dbf"
++++++++++++++++++2-End++++++++++++++++
########################## checking alert_log end Sun Feb 12.*2012##########################
  评论这张
 
阅读(806)| 评论(0)