系统运行性能监控日志

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值