#!/bin/bash
start=$1
end=$2
echo "开始时间: " $1 "结束时间: " $2
cat ***.log | grep _invokeTime | awk -F '"' '{if($4>"2019-11-13 18:47:00")print}'| awk -F '"' '{print substr($0,index($0,"_tid":"") + 7, 36) " ",substr($0,index($0,""_invokeTime":"":"") + 17, 16) }' | sort -t ' ' -k 2 > f1.txt;
cat * | grep _invokeCost | grep -v '_errorMessage'| awk -F '"' '{print substr($0,index($0,"_trackId":"") + 11, 36)" ", substr($0,index($0,"_invokeCost":"") + 16, index($0,""_invokeStatus") - 17)}'> f2.txt;
awk 'NR==FNR{a[$1]=$2" "$3}NR>FNR{if(a[b=$1]){print$1","a[b]","$1","$2}}' f1.txt f2.txt > f3.txt;
cat f3.txt | awk -F ',' '{a[$2] += 1;if($4<100)b[$2] +=1;if($4<200&&$4>100)c[$2] +=1;if($4<300&&$4>200)d[$2] +=1;if($4<500&&$4>300)e[$2] +=1;if($4<1000&&$4>500)f[$2] +=1;if($4>1000)g[$2] +=1;} END {for (i in a) printf("{"time":"%s","c:<100ms":%d,"c:100-200ms":%d,"c:200-300ms":%d,"c:300-500ms":%d,"c:500-1000ms":%d,"c:>1000ms":%d}
", i, b[i], c[i], d[i], e[i], f[i], g[i]);}' > performace.log;
cat performace.log | sort -n -k 2 -t'"' > logwithwort.log
-----------------------------
cat ***.log | grep "2019-11-13" | awk -F" " '{if ($2>"18:47:03" && $2<"18:53:31")print $0}'| grep "update utility table error" | wc -l
cat ***.log | grep "2019-11-13" | awk -F" " '{if ($2>"18:47:03" && $2<"18:53:31")print $0}' | grep "has cost:" | awk -F"cost:" '{if($2!="{}" && $2>1000) print $0}' | wc -l