zoukankan      html  css  js  c++  java
  • 一个日志的分析脚本

    1. #!/bin/bash
    2. cat << EOF
    3. ------------------------------------
    4. 日志分析小工具
    5. ------------------------------------
    6. EOF
    7.  
    8. LANG=en_US
    9.  
    10. Usage() {
    11. echo "Usage: $0 Logfile"
    12. }
    13.  
    14. if [ $# -eq 0 ] ;then
    15. Usage
    16. exit 0
    17. else
    18. Log=$1
    19. fi
    20.  
    21. Tmpfile=$(mktemp)
    22.  
    23. Year=$(date |awk '{print $6}')
    24. Mon=$(date |awk '{print $2}')
    25. Day=$(date |awk '{print $3}')
    26.  
    27. Yesterday=$((Day-1))
    28.  
    29. echo -e " 33[31m-------the ${Year}-${Mon}-${Yesterday} log statistics as shown:--------33[0m"
    30.  
    31. echo -e " 33[32m the UV in total yesterday:33[0m "
    32.  
    33. cat $Log| sed -n "/${Yesterday}/${Mon}/${Year}:00/,/${Day}/${Mon}/${Year}:00/p" | awk '{print $7}'|wc -l
    34.  
    35. echo -e " 33[32m Most of the time yesterday:33[0m "
    36.  
    37. cat $Log |awk '{print $4}' |cut -c 14-18 |sort|uniq -c | sort -nr | head -10
    38.  
    39. echo -e " 33[32m Most of the page yesterday:33[0m "
    40.  
    41. cat $Log |sed -n "/${Yesterday}/${Mon}/${Year}:00/,/${Day}/${Mon}/${Year}:00/p" | awk '{print $11}' |sort |uniq -c |sort -rn |head -10
    42.  
    43. echo -e " 33[32m Most of the ip yesterday:33[0m "
    44.  
    45. cat $Log| sed -n "/${Yesterday}/${Mon}/${Year}:00/,/${Day}/${Mon}/${Year}:00/p" | awk '{print $1}' | sort |uniq -c |sort -rn |head -10 > $Tmpfile
    46. cat $Tmpfile | while read line;
    47. do
    48. num=$(echo $line|awk '{print $1}')
    49. echo -n "访问次数:$num "
    50. ip=$(echo $line|awk '{print $2}')
    51. curl -s ip.cn?ip=$ip
    52. done
  • 相关阅读:
    Delphi WinAPI SetLocaleInfo / GetLocaleInfo
    语言环境代码LCID对照表
    Delphi WinAPI SetThreadLocale
    光刻技术发展
    关于TVM的点滴记录
    TVM 各个模块总体架构
    TVM 图优化Graph Optimization
    Atomic Layer Deposition原子层沉积技术
    智加VS图森VS嬴彻
    汽车网络处理设计
  • 原文地址:https://www.cnblogs.com/hally/p/9099227.html
Copyright © 2011-2022 走看看