zoukankan      html  css  js  c++  java
  • 统计日志10分钟内出现的次数

    #!/bin/bash
    
    logHome=/data/server/tomcats/tomcat7_8180_apiService/logs
    resultLog=/data/shell/result_fetch.out
    cd $logHome
    filelist=`ls $logHome|grep -w FACEBOOK20140723`
    for file in $filelist
    do
     if test -f $file
       then
          echo "$file :" >>$resultLog
          startTime="00:00:00"
          endTime="00:10:00"
         for time in $(seq 1 144)
          do
          taskCounter=`grep 'use local address:' $file|awk '{print $2}'|awk -F "," '{if($1>="'$startTime'"&&$1<"'$endTime'") {print $1}}'|wc -l`
          errorCounter=`grep 'invalid,change token:' $file|awk '{print $2}'|awk -F "," '{if($1>="'$startTime'"&&$1<"'$endTime'") {print $1}}'|wc -l`
            echo "[$startTime~$endTime]:  抓取总数:$taskCounter    重试总次数:$errorCounter" >> $resultLog
            startTime=$endTime
            temp=$(date +%s -d "$startTime")
            temp=$(($temp+10*60))
            endTime=`date +%T -d "1970-01-01 UTC $temp seconds"`
         done
     fi
    done
    #!/bin/bash
    
    logHome=/data/server/tomcats/tomcat7_8380_controlService/logs
    resultLog=/data/shell/result.out
    cd $logHome
    filelist=`ls $logHome|grep FACEBOOK`
    for file in $filelist
    do
     if test -f $file
       then
          echo "$file :" >>$resultLog
          startTime="00:00:00"
          endTime="00:10:00"
         for time in $(seq 1 144)
          do
            taskCounter=`grep 'doSearchTask===>task:' $file|awk '{print $2}'|awk -F "," '{if($1>="'$startTime'" && $1<"'$endTime'") {print $1}}'|wc -l`
            errorCounter=`grep 'OAuthException,code:613' $file|awk '{print $2}'|awk -F "," '{if($1>="'$startTime'" && $1<"'$endTime'") {print $1}}'|wc -l`
            echo "[$startTime~$endTime]:  任务总数:$taskCounter  异常总数:$errorCounter" >> $resultLog
            startTime=$endTime
            temp=$(date +%s -d "$startTime")
            temp=$(($temp+10*60))
            endTime=`date +%T -d "1970-01-01 UTC $temp seconds"`
         done
     fi
    done
  • 相关阅读:
    通过Form添加数据到数据库里
    如何取消服务器/主机空间目录脚本的执行权限
    一个人的网站开发
    3.1.2 新版视频教程震撼发布(30集)
    P类问题,NP,NPC,HPHard,coNP,NPI问题 的简单认识
    随机算法与近似算法
    python to exe
    ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
    anaconda + pyqt5 + pycharm 安装,测试
    C++ 结构体初始化
  • 原文地址:https://www.cnblogs.com/cornerxin/p/9300146.html
Copyright © 2011-2022 走看看