#!/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
本文转自 freeterman 51CTO博客,原文链接:http://blog.51cto.com/myunix/1601035,如需转载请自行联系原作者