日志分析平台 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

 

相关文章:

  • 2021-08-02
  • 2021-10-10
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-12-29
猜你喜欢
  • 2021-12-01
  • 2021-10-19
  • 2022-02-19
  • 2021-11-29
  • 2021-12-01
  • 2021-11-06
相关资源
相似解决方案