Monitor network traffic volume over interface
Solution 1:
The data you want to see shows up in good old ifconfig.
watch ifconfig eth0
or to make things stand out better:
watch -n 1 -d ifconfig eth0
Solution 2:
I use iftop command. It shows statistics in realtime.
iftop -i eth0
Checkout some sceenshots here:
http://www.thegeekstuff.com/2008/12/iftop-guide-display-network-interface-bandwidth-usage-on-linux/
Solution 3:
Without installing new tools:
while ifconfig eth0 | grep 'RX bytes'; do sleep 10; done
Solution 4:
on post-2015 or so linux this might be better
watch -n1 -d ip -s link show [interface]
Solution 5:
function humanValue()
{
h=( '' K M G T P )
i=1; v=$(( $1 * 8 ))
while [ $v -gt $(( 1 << 10 * i )) ]; do let i++; done;
echo -n "$(( $v >> 10 * --i )) ${h[i]}b/s";
}
ifaces=$(ip addr | grep -E "^[0-9]:" | cut -d" " -f2 | tr -d \:)
declare -A RX2 TX2;
while sleep 1;
do
date
for INTERFACE in $ifaces;
do
RX1=$(cat /sys/class/net/${INTERFACE}/statistics/rx_bytes)
TX1=$(cat /sys/class/net/${INTERFACE}/statistics/tx_bytes)
DOWN=$(( RX1 - RX2[$INTERFACE] ))
UP=$(( TX1 - TX2[$INTERFACE] ))
RX2[$INTERFACE]=$RX1; TX2[$INTERFACE]=$TX1
echo -e "[ $INTERFACE:\tRX: $(humanValue $DOWN)\t|\tTX: $(humanValue $UP) ]"
done;
done;