• web服务器错误日志截取及各类代码统计


    #/bin/sh
    #*********************
    # get url error log
    #*********************

    curday=`date '+%Y-%m-%d %H:%M:%S'`
    echo "input log file dir!"
    read logdir
    Code=`awk -F '[ "]+' '{print $all}' $logdir|grep 'GET'|grep '500'`
    echo "Do you want to do $1 out "Web_Code" count ? (y/n) (default: n) __"
    read do
    do=${do:=n}
    if [ "$do" = "y" ];then
    echo "Out put web code in "/home/count.log" file!\n"
    error_501=$(awk -F '[ " ]' '{print $all}' $logdir|grep "501"|wc -l)
    echo "$curday:URL error_501 count:$error_501" >>/home/count.log
    error_500=$(awk -F '[ " ]' '{print $all}' $logdir|grep "500"|wc -l)
    echo "$curday:URL error_500 count:$error_500" >>/home/count.log
    error_404=$(awk -F '[ " ]' '{print $all}' $logdir|grep "404"|wc -l)
    echo "$curday:URL error_404 count:$error_404" >>/home/count.log
    error_403=$(awk -F '[ " ]' '{print $all}' $logdir|grep "403"|wc -l)
    echo "$curday:URL error_403 count:$error_403" >>/home/count.log
    error_400=$(awk -F '[ " ]' '{print $all}' $logdir|grep "400"|wc -l)
    echo "$curday:URL error_400 count:$error_400" >>/home/count.log
    ok_200=$(awk -F '[ " ]' '{print $all}' $logdir|grep "200"|wc -l)
    echo "$curday:URL OK_200 count:$ok_200" >>/home/count.log
    fi
    echo $Code >>/home/error.log
    sleep 2
    echo "exit"
    exit 0

  • 相关阅读:
    stm32入门
    Shell入门
    广播与组播
    超时接收
    socket的四种IO模型
    网络套接字socket
    网络基础
    慢速系统调用被中断
    C# 程序运行时间计算
    HTTP的传输编码(Transfer-Encoding:chunked) / net::ERR_INVALID_CHUNKED_ENCODING
  • 原文地址:https://www.cnblogs.com/zksfyz/p/5479689.html
Copyright © 2020-2023  润新知