网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

获取两天内的告警日志(AIX|ksh|shell|oracle)-创新互联

#!/u

成都创新互联是一家专注于成都网站建设、成都网站制作与策划设计,金寨网站建设哪家好?成都创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:金寨等地区。金寨做网站价格咨询:18982081108sr/bin/ksh
#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=`TZ=aaa24 date +'%a %b %d '`
tday=`date +'%a %b %d '`
yday_num=`TZ=aaa24 date +'%F'`
tday_num=`date +'%F'`
yday_md=`TZ=aaa24 date +'%m%d'`.*`TZ=aaa24 date +'%y'`
tday_md=`date +'%m%d'`.*`date +'%y'`
yday_lis=`TZ=aaa24 date +'%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
errpt | head -1 >> $log_name
errpt | egrep "${yday_md}|${tday_md}"  >> $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];
let count_1+=1
day_mid=$(echo "$line" | egrep "${yday}|${tday}")
if [[ -n $day_mid ]];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];
let count_1+=1
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"
count_2=0
while read line
do
#  count_2=$[$count_2+1]
let 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];
let count_1+=1
day_mid=$(echo "$line" | egrep "${yday_num}|${tday_num}")
if [[ -n $day_mid ]];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];
let count_1+=1
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"
count_2=0
while read line
do
#  count_2=$[$count_2+1]
let 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];
let count_1+=1
day_mid=$(echo "$line" | egrep "${yday_lis}|${tday_lis}")
if [[ -n $day_mid ]];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];
let count_1+=1
fi
echo "当前指针位置:${count_1} 文件行数:${count_3} 文件名:${file_name}"
count_2=0
while read line
do
#  count_2=$[$count_2+1]
let 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/ebiz/ebiz1/trace/alert_ebiz1.log
echo "############################asm_log#########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name
chk_db_log /u01/app/grid/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.3/grid/log/ecpdb1/alertecpdb1.log
echo "########################listener_log########################################" >> $log_name
echo "" >> $log_name
echo "" >> $log_name
##############11g###########################
chk_grid_log /u01/app/grid/diag/tnslsnr/ecpdb1/listener/alert/log.xml
##############11g###########################
##############10g###########################
#chk_listener_log /u01/app/oracle/diag/tnslsnr/zhangr/listener/trace/listener.log
##############10g###########################

文章名称:获取两天内的告警日志(AIX|ksh|shell|oracle)-创新互联
标题URL:http://bjjierui.cn/article/dhjgpc.html

其他资讯