监控网卡流量

#!/bin/bash

networknum()

{

rx1=$(ifconfig $1|grep "RX bytes"|awk '{print $2}'|awk -F: '{print $2}')

sleep $2

rxa=$(($rx1 / 1024))

rx2=$(ifconfig $1|grep "RX bytes"|awk '{print $2}'|awk -F: '{print $2}')

rxb=$(($rx2 / 1024))

echo "Net Traffic is:" $(($rxb - $rxa))k/s

}


if [ $# -eq 3 ];then

        timenum=$3

else

        timenum=-1

fi


while (($timenum))

do

        networknum $1 $2

        timenum=$(($timenum -1))

        

done




你可能感兴趣的:(sleep,网卡,流量)