linux shell awk grep 日志分析 统计

awk grep wc 组合进行日志分析,统计
统计参数:按日期统计
日期格式:统计数据用[]包含;每行数据中包含日期字符串;关键字区分特定的业务逻辑

#!/bin/bash


stat_time=$1

if [ ! -n "$stat_time" ]; then

echo "please put a stat time !"
read time
stat_time=$time

if [ ! -n "$stat_time" ]; then
echo "you put stat_time is null! stat end !"
exit
fi

fi

echo "you put stat time is:$stat_time"

stat_path="/home/java小生/tigermachine_stat"
stat_file_path=""

if [ ! -x "$stat_path" ];then

mkdir $stat_path ;
fi

stat_file_path=$stat_path/stat.log

cat catalina.out |grep $stat_time | grep "changeTigerMachinePoker gameCost" > $stat_file_path
cat catalina.out |grep $stat_time | grep "tiger machine spinWin pokerType" >> $stat_file_path


changePokerTotalCost=`cat $stat_file_path |grep 'changeTigerMachinePoker gameCost'|awk -F[][] '{print $6}' |awk 'BEGIN{total=0}{totalCost+=$1}END{print totalCost}'`

spinTigerMachenCost=`cat $stat_file_path |grep 'tiger machine spinWin pokerType'|awk -F[][] '{print $10}'|awk 'BEGIN{total=0}{totalCost+=$1}END{print totalCost}'`

systemAwardTotal=`cat $stat_file_path |grep 'tiger machine spinWin pokerType' |awk -F[][] '{print $12}'|awk 'BEGIN{total=0}{totalCost+=$1}END{print totalCost}'`

echo "changePokerTotalCost:$changePokerTotalCost"
echo "spinTigerMachineCost:$spinTigerMachenCost"
echo "systemAwardTotal:$systemAwardTotal"
echo "kingNumber:`cat $stat_file_path |grep "pokerType\[1\]"|wc -l`"
echo "baoziNumber:`cat $stat_file_path |grep "pokerType\[2\]"|wc -l`"
echo "shunjinNumber:`cat $stat_file_path |grep "pokerType\[3\]"|wc -l`"
echo "dilongNumber:`cat $stat_file_path |grep "pokerType\[4\]"|wc -l`"
echo "jinhuaNumber:`cat $stat_file_path |grep "pokerType\[5\]"|wc -l`"
echo "shunziNumber:`cat $stat_file_path |grep "pokerType\[6\]"|wc -l`"
echo "duiziNumber:`cat $stat_file_path |grep "pokerType\[7\]"|wc -l`"
echo "zapaiNumber:`cat $stat_file_path |grep "pokerType\[8\]"|wc -l`"
echo "2huaNumber:`cat $stat_file_path |grep "pokerType\[9\]"|wc -l`"
echo "1huaNumber:`cat $stat_file_path |grep "pokerType\[10\]"|wc -l`"

exit 0 ;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值