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"
  • 相关阅读:
    svn不提交.net项目中的bin
    java 与C# 时间格式 交互
    生成菜单序列号
    ashx 方法模板
    webservice使用方法
    如何配置IIS服务器?
    zepto.fullpage
    模拟单选框
    star score
    Hover show tips
  • 原文地址:https://www.cnblogs.com/ip99/p/14890694.html
Copyright © 2011-2022 走看看