码迷,mamicode.com
首页 > 其他好文 > 详细

awk脚本分析日志

时间:2020-04-17 15:59:13      阅读:68      评论:0      收藏:0      [点我收藏+]

标签:users   成功   style   user   mic   critical   测试   inf   ==   

#######################统计日志中测试人员执行用例个#############################
 
技术图片
 
BEGIN{
printf "%-10s%-10s\n","Tester","TotalTestcases"
}
{
USERS[$4] += 1
}
END{
for(u in USERS)
printf "%-10s%-10d\n",u,USERS[u]
}
 
awk -f test.awk log.txt
技术图片

 

 

 
#############################################################################
 
######################分别统计每位测试人员执行用例成功和失败的总数################
技术图片

 

 

BEGIN{
printf "%-10s%-10s%-10s\n","Tester","PassTotal","FailTotal"
}
{
if ($5 == "Pass")
{
SUCCESS[$4] += 1
}else{
FAIL[$4] += 1
}
USERS[$4] += 1
}
END{
for(u in USERS)
printf "%-10s%-10s%-10s\n",u,SUCCESS[u],FAIL[u]
}
 
awk -f test.awk log.txt
技术图片

 

 

 
#############################################################################
 
#####################分别统计每位测试人员执行用例CRITICAL、ERROR日志等级数以及所有测试人员每项总数################
技术图片

 

 

BEGIN{
printf "%-10s\t%-10s\t%-10s\t%-10s\t%-10s\t\n","Tester","ErrorTotlal","CriticalTotal","PassTotal","FailTotal"
}
{
if ($5 == "Pass")
{
SUCCESS[$4] += 1
}else{
FAIL[$4] += 1
}
if ($3 == "ERROR")
{
ERROR[$4] += 1
}
if ($3 == "CRITICAL")
{
CRITICAL[$4] += 1
}
USERS[$4] += 1
}
END{
for(u in USERS)
{
ALL_ERRORS += ERROR[u]
ALL_CRITICALS += CRITICAL[u]
ALL_SUCCESS += SUCCESS[u]
ALL_FAILS += FAIL[u]
printf "%-10s\t%-10s\t%-10s\t%-10s\t%-10s\t\n",u,ERROR[u],CRITICAL[u],SUCCESS[u],FAIL[u]
}
printf "%-10s\t%-10s\t%-10s\t%-10s\t%-10s\t\n","Total",ALL_ERRORS,ALL_CRITICALS,ALL_SUCCESS,ALL_FAILS
}
 
awk -f test.awk log.txt
技术图片

 

 

 
#############################################################################

awk脚本分析日志

标签:users   成功   style   user   mic   critical   测试   inf   ==   

原文地址:https://www.cnblogs.com/yanpan/p/12720016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!