网站建设资讯

NEWS

网站建设资讯

oracle中如何获取两天内的告警日志

这篇文章将为大家详细讲解有关oracle中如何获取两天内的告警日志,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

成都创新互联的客户来自各行各业,为了共同目标,我们在工作上密切配合,从创业型小企业到企事业单位,感谢他们对我们的要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。专业领域包括成都网站设计、成都做网站、外贸网站建设、电商网站开发、微信营销、系统平台开发。

#!/bin/bash
#author: Rui Zhang
#date: 2017-08-09
#email: sharpzhang_2008@126.com 
export LANG=en_US.UTF-8


dir_name=/tmp/tday_log/
log_name=/tmp/tday_log/tday_log_`date +'%F'`
log_name=/tmp/tday_log/10.4.57.129_tday_`date +'%F'`.log
yday=`date -d -1day +'%a %b %d '`
tday=`date +'%a %b %d '`
yday_num=`date -d -1day +'%F'`
tday_num=`date +'%F'`
yday_md=`date -d -1day +'%b %e '`
tday_md=`date +'%b %e '`
yday_lis=`date -d -1day +'%d-%b-%Y ' | tr [a-z] [A-Z]`
tday_lis=`date +'%d-%b-%Y ' | tr [a-z] [A-Z]`


if [ ! -d "$dir_name" ];then
  mkdir -p $dir_name
fi


if [ -f "$log_name" ];then
  rm -f $log_name
fi




echo "###########################/var/log/messages################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name
egrep "${yday_md}|${tday_md}" /var/log/messages >> $log_name
#egrep "Jul\  3|Jul\  2" /var/log/messages >> $log_name
echo "" >> $log_name


function chk_db_log(){
file_name=$1
count_1=0
while read line
do
  count_1=$[$count_1+1];
if [[ $line =~ $yday ]];then
break
elif [[ $line =~ $tday ]];then
break
fi
done <$file_name


count_3=`wc -l ${file_name} |awk {'print $1'}`


if [ "$count_1" = "$count_3" ];then
 count_1=$[$count_1+1];
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"


count_2=0
while read line
do
  count_2=$[$count_2+1]
if (($count_2>=count_1));then
echo "$line" >>$log_name
fi
done <$file_name


echo "" >> $log_name
}




function chk_grid_log(){
file_name=$1
count_1=0
while read line
do
  count_1=$[$count_1+1];
if [[ $line =~ $yday_num ]];then
break
elif [[ $line =~ $tday_num ]];then
break
fi
#  echo $line
#echo $count_1
#done <'/u01/app/oracle/diag/rdbms/test/test1/trace/alert_test1.log'
done <$file_name
#echo $count_1


count_3=`wc -l ${file_name} |awk {'print $1'}`


if [ "$count_1" = "$count_3" ];then
 count_1=$[$count_1+1];
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"


count_2=0
while read line
do
  count_2=$[$count_2+1]
if (($count_2>=count_1));then
echo "$line" >>$log_name
fi
#done <'/u01/app/oracle/diag/rdbms/test/test1/trace/alert_test1.log'
done <$file_name


echo "" >> $log_name
}


function chk_listener_log(){
file_name=$1
count_1=0
while read line
do
  count_1=$[$count_1+1];
if [[ $line =~ $yday_lis ]];then
break
elif [[ $line =~ $tday_lis ]];then
break
fi
#  echo $line
#echo $count_1
#done <'/u01/app/oracle/diag/rdbms/test/test1/trace/alert_test1.log'
done <$file_name
#echo $count_1


count_3=`wc -l ${file_name} |awk {'print $1'}`


if [ "$count_1" = "$count_3" ];then
 count_1=$[$count_1+1];
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"


count_2=0
while read line
do
  count_2=$[$count_2+1]
if (($count_2>=count_1));then
echo "$line" >>$log_name
fi
#done <'/u01/app/oracle/diag/rdbms/test/test1/trace/alert_test1.log'
done <$file_name


echo "" >> $log_name
}
#echo $count_1


echo "############################db_log##########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name


chk_db_log /u01/app/oracle/diag/rdbms/test/test1/trace/alert_test1.log


echo "############################asm_log#########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name


chk_db_log /u01/app/oracle/diag/asm/+asm/+ASM1/trace/alert_+ASM1.log


echo "############################grid_log########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name


chk_grid_log /u01/app/11.2.0/grid/log/zhangr/alertzhangr.log


echo "########################listener_log########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name


##############11g###########################
#chk_grid_log /u01/app/oracle/diag/tnslsnr/zhangr/listener/alert/log.xml
##############11g###########################




##############10g###########################
chk_listener_log /u01/app/oracle/diag/tnslsnr/zhangr/listener/trace/listener.log
##############10g###########################

关于“oracle中如何获取两天内的告警日志”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


网页题目:oracle中如何获取两天内的告警日志
地址分享:http://njwzjz.com/article/pgiees.html