zoukankan      html  css  js  c++  java
  • 系统运行性能监控日志

    日志分析平台 kibana+ES 日志分析工具,量一个比较好的查询分析平台。


    5 0 * * * /home/xx/performance/restart.sh
    */1 * * * * /home/xx/performance/df.sh

    run.sh

    #!/bin/bash
    
    dir=`dirname "$0"`
    today=`date +%Y-%m-%d`
    cd "$dir"
    echo "$$" > run.pid
    
    if [ ! -d dat ];then
       mkdir dat
    fi
    
    vmstat 1|stdbuf --output=0 sed -e "1d" -e "/^\s*(procs|r)/d" |stdbuf -oL awk '{if($15<50||$4<1048576) print strftime("%H:%M:%S")" X "$0; else print strftime("%H:%M:%S")" N "$0;}' >> "dat/$today.log" 2>err.log

    restart.sh

    #!/bin/bash
    
    dir=`dirname "$0"`
    cd "$dir"
    
    
    oldlogs=`find ./ -mtime +30 -name "*.log"|wc -l`
    find ./dat/ -mtime +30 -name "*.log" -exec rm -rf {} ;
    
    echo "delete old log :$oldlogs files"
    
    pid=`cat run.pid`
    ps --ppid $pid|sed "1d"|awk '{print $1}'|xargs kill -9
    kill -9 $pid
    
    echo "killed pid $pid"
    nohup ./run.sh > /dev/null 2>err.log &
    
    echo 'done'

     ping监控

    ping -i 0.2 baidu.com|awk -F ' |=' '{if($11!=""&&$11<1000);else print $0;}'

    df.sh

    #!/bin/bash
    
    dir=`dirname "$0"`
    today=`date +%Y-%m-%d`
    cd "$dir"
    echo "$$" > run.pid
    
    if [ ! -d dat ];then
       mkdir dat
    fi
    
    df -h|awk  '{match($0,/([0-9]+)\%/,a);if(a[1]>80)print strftime("%Y-%m-%d %H:%M:%S")" "$0;}'  >> dat/"df_$today.log" 2>&1
  • 相关阅读:
    文件重名问题
    文件上传
    回顾IO流
    Freemarker
    中文乱码问题
    Filter(过滤器)
    Ajax
    jQuery
    普华操作系统,开机无法进入桌面程序; 解决多次source /etc/profile的烦恼
    C++ 文件类型判别错误,将目录文件识别为普通文件
  • 原文地址:https://www.cnblogs.com/a-xu/p/9142066.html
Copyright © 2011-2022 走看看