系统运行性能监控日志

日志分析平台 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
原文地址:https://www.cnblogs.com/a-xu/p/9142066.html