获取nginx日志状态码百分比脚本

#!/bin/bash
pwd=/app/nginx/logs/access.log
 for num1 in `cat $pwd | awk '{print $9}' | grep -Ei "^4|^5" | wc -l`
  do
  echo 异常状态码总数:$num1
 for num2 in `cat $pwd | awk '{print $9}'| wc -l`
  do
   echo 请求状态码总数:$num2
  k=$(echo "scale=2;$num1 * 100 / $num2"| bc)%
 echo 异常百分比:$k
  done
 done

  

posted @ 2021-03-04 22:16  tigergaonotes  阅读(176)  评论(0编辑  收藏  举报