本文共 1801 字,大约阅读时间需要 6 分钟。
- ###################### 昨天的日期 #########################################
- YESTERDAY()
- {
- YY=`date '+%Y'`
- MM=`date '+%m'`
- DD=`date '+%d'`
-
- #echo $YY
- #echo $MM
- #echo $DD
-
- if [ $DD-1 -eq 0 ]
- then
- MM=`expr $MM - 1`
- if [ $MM -lt 10 ] && [ $MM -gt 0 ]
- then
- MM=0$MM
- elif [$MM -eq 0]
- then
- MM=12
- else
- MM=$MM
- fi
-
- case $MM in
- 2)
- DD=28
- ;;
- 4)
- DD=30
- ;;
- 6)
- DD=30
- ;;
- 9)
- DD=30
- ;;
- 11)
- DD=30
- ;;
- *)
- DD=31
- ;;
- esac
-
- else
- DD=`expr $DD - 1`
- if [ $DD -lt 10 ]
- then
- DD=0$DD
- fi
-
- fi
- case $1 in
- DF) echo $YY$MM$DD ;;
- DT) echo $MM-$DD ;;
- esac
- }
-
- #################################### END ######################################################
-
- #时间格式:20111107
- #DF=`date '+ %Y%m%d' -d '-1 day'
- DF=`YESTERDAY DF`
- DT=`YESTERDAY DT`
- FILENAME=monrev
- DIR=/home/view/monrev
- CSTJ=/home/view/cstj
- SWFILE=/ag/switch/switch/log/debug/swMonrev*
-
- #echo $DF
- #echo $DT
- #exit
-
-
- if [ ! -d $DIR ]
- then
- mkdir $DIR
- fi
-
-
- echo "开始生成tranid文件"
- grep -h "^lTranid" $SWFILE >$DIR/tranid.txt
- echo "开始生成trancode文件"
- grep -h "^aTrancode" $SWFILE >$DIR/trancode.txt
- echo "开始生成time文件"
- grep -h "十六进制报文(开始)" $SWFILE >$DIR/time.txt
- echo "开始生成mail文件"
- grep -h "iDes_q" $SWFILE >$DIR/mail.txt
-
- echo "最终文件开始生成......"
- #删除昨天的超时统计文件
- rm -rf $CSTJ/cstj.tmp
-
- NU=`cat $DIR/time.txt |wc -l`
- N=1
- until [ $N -eq $NU ]
- do
-
- A=`sed -n $(($N))p $DIR/tranid.txt`
- B=`sed -n $(($N))p $DIR/trancode.txt`
- C=`sed -n $(($N))p $DIR/time.txt |awk '{print $1 " " $2}'`
- D=`sed -n $(($N))p $DIR/mail.txt`
- echo $D $C >>$CSTJ/cstj.tmp
- echo $A $B $C $D|grep "$DT" >>$DIR/$FILENAME.$DF
- N=`expr $N + 1`
- done
- echo "文件生成完毕!"
- echo "超时统计开始"
- #################超时统计###############################################
- for i in `cat $CSTJ/cstj.ini`
- do
- num=`grep "$DT" $CSTJ/cstj.tmp|grep "\[$i\]" | wc -l | awk '{print $1}'`
- echo "$num" >>$CSTJ/$DF.txt
- done
- echo "超时统计结束"
- #rm -rf $CSTJ/cstj.tmp
转载于:https://blog.51cto.com/bxbx258/744989