獲取兩天內的告警日誌(AIX|ksh|shell|oracle)
#!/usr/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###########################
#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###########################
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29802484/viewspace-2144388/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 獲取兩天內的告警日誌(bash|shell|oracle)Oracle
- 獲取一週內的告警日誌(python|Oracle)PythonOracle
- Zabbix如何監控Oracle的告警日誌Oracle
- Oracle告警日誌ora-04030Oracle
- oracle12告警日誌檔案?Oracle
- 使用外部表管理Oracle 告警日誌Oracle
- Oracle 11g 中告警日誌的位置Oracle
- ORACLE 告警日誌alert過大的處理Oracle
- 利用外部表讀取告警日誌檔案
- 【ELK】elastalert 日誌告警AST
- 告警日誌介紹
- Oracle之備份和清理監聽日誌、告警日誌指令碼Oracle指令碼
- RAC的告警日誌檔案
- Oracle 跟蹤/告警/監聽日誌的清理指令碼Oracle指令碼
- Oracle的告警日誌之v$diag_alert_ext檢視Oracle
- js獲取兩個時間相差的天數JS
- 智慧手環core日誌獲取
- 智慧手環guard日誌獲取
- 獲取Tomcat更詳細的日誌Tomcat
- Oracle 自動化運維-Python監控Oracle告警日誌Oracle運維Python
- 告警日誌出現kewastUnPackStats資訊AST
- ELK日誌告警elastalert2AST
- AIX系統日誌AI
- AIX 系統日誌AI
- AIX基礎日誌AI
- shell分割日誌
- ORACLE dump kshOracle
- DB2_獲取診斷日誌DB2
- 【轉】oracle學習筆記(三)之檢查Oracle的告警日誌檔案Oracle筆記
- AIX 下關日誌燈的方法AI
- Oracle redo日誌內容探索(一)Oracle Redo
- 獲取有關 Linux shell 內建命令的幫助Linux
- 使用 adb 命令獲取指定應用的日誌
- 使用外部表管理Oracle 告警日誌(ALAERT_$SID.LOG)Oracle
- 日誌服務之告警接入與管理
- Oracle redo日誌內容探索之二Oracle Redo
- 本地檔案包含之包含日誌獲取webshellWebshell
- 【shell】日誌切割指令碼指令碼