设置日志输出阈值

设置日志输出阈值

我必须检查日志并监视 I/O 输出,日志是每秒生成的 我似乎很难监视每秒生成的日志,我正在寻找一些awk命令,它只提供该行的输出超过 210.00 之上的阈值或降至 180.00 以下

有没有办法获得唯一超过阈值的输出

示例输出:

Jun 20, 2016  interval        i/o   MB/sec   bytes   read     resp     read    write     resp     resp queue  cpu%  cpu%
                             rate  1024**2     i/o    pct     time     resp     resp      max   stddev depth sys+u   sys
13:28:40.040      6571     190.00    23.75  131072  77.89   80.840   80.827   80.885   90.911    2.783  15.4   0.1   0.1
13:28:41.041      6572     198.00    24.75  131072  79.29   80.800   80.491   81.984   94.508    2.865  16.0   0.0   0.0
13:28:42.041      6573     198.00    24.75  131072  85.35   80.803   80.719   81.295   90.176    2.650  16.0   0.0   0.0
13:28:43.041      6574     198.00    24.75  131072  79.29   80.813   80.789   80.902   92.090    2.687  16.0   0.0   0.0
13:28:44.041      6575     197.00    24.63  131072  80.20   81.195   81.020   81.905   91.351    3.385  16.0   0.0   0.0
13:28:45.041      6576     198.00    24.75  131072  85.35   80.805   80.814   80.752   90.865    2.795  16.0   0.0   0.0
13:28:46.040      6577     198.00    24.75  131072  80.81   80.816   80.733   81.166   94.233    2.946  16.0   0.0   0.0
13:28:47.040      6578     198.00    24.75  131072  78.28   80.810   80.746   81.042   91.541    2.882  16.0   0.0   0.0
13:28:48.040      6579     198.00    24.75  131072  79.29   80.784   80.788   80.770   92.255    2.799  16.0   0.1   0.0
13:28:49.041      6580     197.00    24.63  131072  82.23   80.811   80.637   81.619   94.005    3.311  16.0   0.0   0.0
13:28:50.041      6581     199.00    24.88  131072  81.41   80.829   80.678   81.489   90.607    2.851  16.0   0.0   0.0

答案1

如果您希望第 3 列的所有行都超出您的限制,那么只需

awk '$3>=210 || $3<=180 {print}'

如果您只想要第一行,直到数据回到限制范围内,那么:

awk '$3>=210 { if(!hi)print; hi=1; lo=0; next } 
     $3<=180 { if(!lo)print; lo=1; hi=0; next }
     { hi = 0; lo = 0 }'

相关内容