awk计算丢包率

来源:互联网 发布:jquery获取表单数据 编辑:程序博客网 时间:2024/06/06 14:20
  1. #author souroot
  2. #email: souroot@163.com
  3. #we use formular: (all the send packets in agents layer)
  4. #-(all the recieve packets in agents layer) as all the lost packets
  5. BEGIN{
  6.     send;
  7.     recv;
  8. }
  9. {
  10.     if(($1)=="s" && ($4)=="AGT")
  11.         send++;
  12.     if(($1)=="r" && ($4)=="AGT")
  13.         recv++;
  14. }
  15. END{
  16.     printf "send is %d, recv is %d\n",send,recv;
  17.     printf "drop rate is %4f\n",(send-recv)/send;
  18. }

 注意:$1代表第一列,$4代表第四列。BEGIN表示循环开始,END表示循环结束
0 0
原创粉丝点击