zoukankan      html  css  js  c++  java
  • 13 Nginx访问日志分析

    #!/bin/bash
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    # Nginx 日志格式:
    #    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                      '$status $body_bytes_sent "$http_referer" '
    #                      '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr';
    
    LOG_FILE=$1
    
    echo "--------------统计访问最多的10个IP-----------------------------"
    awk '{a[$1]++} END {print "UV:", length(a)}' $LOG_FILE
    awk '{a[$1]++} END {for(v in a) print v, a[v]}' $LOG_FILE | sort -k2 -nr | head -10
    
    echo "--------------统计时间段访问最多的10个IP-----------------------"
    awk '$4 >= "[13/Jul/2020:13:00:00" && $4 <= "[13/Jul/2020:17:00:00" {a[$1]++} END {for(v in a) print v, a[v]}' $LOG_FILE | sort -k2 -nr | head -10
    
    echo "--------------统计访问最多的10个页面---------------------------"
    # awk '{a[$7]++} END {print "PV:", length(a)}' $LOG_FILE
    echo "PV: `awk '{print $7}' $LOG_FILE | wc -l`"
    awk '{a[$7]++} END {for(v in a) print v, a[v]}' $LOG_FILE | sort -k2 -nr | head -10
    
    echo "--------------统计访问页面状态码数量最多的10个页面-------------"
    awk '{a[$7" "$9]++} END {for(v in a) print v, a[v]}' $LOG_FILE | sort -k3 -nr | head -10
  • 相关阅读:
    Java对于私有变量“反思暴力”技术
    图形界面汇总
    【j2ee spring】27、巴巴荆楚网-整合hibernate4+spring4(2)
    .net Work Flow 4.0
    Drainage Ditches
    Google 开源项目的风格指南
    2015第53周一
    2015第52周日
    2015第52周六
    2015第52周五
  • 原文地址:https://www.cnblogs.com/LiuChang-blog/p/14697972.html
Copyright © 2011-2022 走看看