zoukankan      html  css  js  c++  java
  • linux 统计网卡带宽脚本

    #!/bin/sh
    netcard=`ip l show|grep -Ev "macvlan|ppp"|grep ens|awk -F ":" '{print $2}'`
    txbyte1=0
    rxbyte1=0
    txbyte2=0
    rxbyte2=0
    for i in $netcard;do
    ##echo "$i ====>
    "
    txbyte1=$((`ifconfig $i|grep -E "TX.+packets"|awk '{print $5}'` + $txbyte1))
    rxbyte1=$((`ifconfig $i|grep -E "RX.+packets"|awk '{print $5}'` + $rxbyte1))
    ##echo "tx:$i: $txbyte1  rx:$i:$rxbyte1"
    done
    sleep 5 
    for i in $netcard;do
    txbyte2=$((`ifconfig $i|grep -E "TX.+packets"|awk '{print $5}'` + $txbyte2))
    rxbyte2=$((`ifconfig $i|grep -E "RX.+packets"|awk '{print $5}'` + $rxbyte2))
    done
    txdiffbyte=$(((txbyte2 - txbyte1)/1024/1024*8/5))
    rxdiffbyte=$(((rxbyte2 - rxbyte1)/1024/1024*8/5))
    
    
    ##echo "$rxbyte1 $rxbyte2 $rxdiffbyte MB/S"
    ##echo "$txbyte1 $txbyte2 $txdiffbyte MB/S"
    echo "download: $rxdiffbyte MB/S  upload:$txdiffbyte MB/S"
  • 相关阅读:
    SQL逻辑查询语句执行顺序
    数据库索引的实现原理
    JAVAMail邮件服务器
    TCP/IP基础
    Java IO流学习总结
    [Lydsy1806月赛] 超速摄像头
    CodeForces
    SCU
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/ip99/p/14890694.html
Copyright © 2011-2022 走看看