zoukankan      html  css  js  c++  java
  • awk脚本分析日志

    #######################统计日志中测试人员执行用例个#############################
     
     
    BEGIN{
    printf "%-10s%-10s ","Tester","TotalTestcases"
    }
    {
    USERS[$4] += 1
    }
    END{
    for(u in USERS)
    printf "%-10s%-10d ",u,USERS[u]
    }
     
    awk -f test.awk log.txt
     
    #############################################################################
     
    ######################分别统计每位测试人员执行用例成功和失败的总数################
    BEGIN{
    printf "%-10s%-10s%-10s ","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 ",u,SUCCESS[u],FAIL[u]
    }
     
    awk -f test.awk log.txt
     
    #############################################################################
     
    #####################分别统计每位测试人员执行用例CRITICAL、ERROR日志等级数以及所有测试人员每项总数################
    BEGIN{
    printf "%-10s %-10s %-10s %-10s %-10s ","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 %-10s %-10s %-10s %-10s ",u,ERROR[u],CRITICAL[u],SUCCESS[u],FAIL[u]
    }
    printf "%-10s %-10s %-10s %-10s %-10s ","Total",ALL_ERRORS,ALL_CRITICALS,ALL_SUCCESS,ALL_FAILS
    }
     
    awk -f test.awk log.txt
     
    #############################################################################
  • 相关阅读:
    php工作笔记5-css定位
    php工作笔记4-mysql笔记1
    php工作笔记3-php基础加强
    php工作笔记2-php编码效率
    php工作笔记1-数组常用方法总结,二维数组的去重,上传图片到oss服务器
    android浏览器 源码共享
    违章查询源码分享
    CENTOS 6.5 配置YUM安装NGINX
    Linux下安装Oracle11g服务器
    ARCGIS SDE空间化处理
  • 原文地址:https://www.cnblogs.com/yanpan/p/12720016.html
Copyright © 2011-2022 走看看