日志滚动每分钟统计一次对应的数据

#!/bin/bash

cpus=$(cat /proc/cpuinfo  | grep processor | tail -1 | cut -d: -f2)
cpus=$((cpus + 1))
time=$(date +'%m%d %H:%M' --date='1 min ago')
#echo $time
used=$(tail -n 10000 /home/admin/logs/log.log 2>/dev/null | grep "$time" | grep abc | wc -l)

total=$(echo "$cpus * 12 / 10" | bc)

if [ -z "$used" ]; then
    used=0
fi

if [ $used -eq -1 ]; then
    used=$total
fi

#echo "$used $total"
echo "$used"

 

日志滚动,每分钟统计一次对应的数据。

 

待续

posted @ 2017-07-05 16:07  宝山方圆  阅读(613)  评论(0编辑  收藏  举报