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
on post-2015 or so linux this might be better
watch -n1 -d ip -s link show [interface]
Solution 4
Without installing new tools:
while ifconfig eth0 | grep 'RX bytes'; do sleep 10; done
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;
Related videos on Youtube
BeeOnRope
Updated on September 18, 2022Comments
-
BeeOnRope over 1 year
Is there a way to monitor the traffic (e.g., get a live view of the utilization) over a particular network interface, say eth0?
The catch here is that the set of tools on the box is fixed, and is pretty much a stock RHEL deployment, so add-on tools can't be used.
Looking for something basic and usually present like iostat here.
-
Andy Smith over 12 yearsHave a look at stackoverflow.com/questions/596590/…. Some of the suggestions on there should be useful.
-
BeeOnRope over 12 yearsD'oh, search fail (and I tried). To be fair, I think it's a serverfault question, not a SO one :)
-
-
BeeOnRope over 12 yearsLooks great, unfortunately I am not able to install any new tools on these locked down boxes.
-
BeeOnRope over 8 yearsThanks - this in addition to the comment by @user239558 was just right. I'm accepting your answer since you were the first to mention
ifconfig
. -
Hazok almost 8 yearsSpot on. This is something I've been looking for and although there are many similar questions to this on different forums, this is the first answer I found that nails it.
-
Kevin about 6 yearsifconfig is not in the default path. /sbin/ifconfig may be required.
-
Al-Alamin about 6 yearsiptraf is exactly what i was looking for. But its last release seems be in IPTraf 3.0.0 - September 19, 2005. can this be a problem?
-
Drakarah about 5 yearsOutput chain should have -o as interface, -i is illegal
-
siikamiika almost 3 yearsBest answer today. You can also use
-h[uman-readable]
withip